package com.sgcc.sx.pmos.e_sx_order.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.CountDownTimer;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ClipboardUtils;
import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.interfaces.OnConfirmListener;
import com.lxj.xpopup.interfaces.OnSelectListener;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.sgcc.sx.pmos.arouter.mall.MallArouterPath;
import com.sgcc.sx.pmos.arouter.order.OrderArouterPath;
import com.sgcc.sx.pmos.common.base.BaseRecyclerAdapter;
import com.sgcc.sx.pmos.common.base.MvpBaseActivity;
import com.sgcc.sx.pmos.common.bean.BaseResponse;
import com.sgcc.sx.pmos.common.bean.EventCenter;
import com.sgcc.sx.pmos.common.bean.IndentOrContractBean;
import com.sgcc.sx.pmos.common.dialog.CommonDialog;
import com.sgcc.sx.pmos.common.http.HttpInterConst;
import com.sgcc.sx.pmos.common.utils.ArguConstant;
import com.sgcc.sx.pmos.common.utils.BigDecimalUtils;
import com.sgcc.sx.pmos.common.utils.DateUtils;
import com.sgcc.sx.pmos.common.utils.DialogUtil;
import com.sgcc.sx.pmos.common.utils.EnumUtils;
import com.sgcc.sx.pmos.common.utils.TextUtil;
import com.sgcc.ln.pmos.common.widget.LoadingLayout;
import com.sgcc.ln.pmos.common.widget.TitleBar;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.e_sx_order.adapter.ConventionPowerAdapter;
import com.sgcc.sx.pmos.e_sx_order.adapter.MonthAdapter;
import com.sgcc.sx.pmos.e_sx_order.bean.ContractElectricityBean;
import com.sgcc.sx.pmos.e_sx_order.bean.EnergyByMonthDetailBean;
import com.sgcc.sx.pmos.e_sx_order.bean.IndentBean;
import com.sgcc.sx.pmos.e_sx_order.bean.OrderInfoOfTableBean;
import com.sgcc.sx.pmos.e_sx_order.bean.OrderTableBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PackageComparisonPriceDetailBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PackageComparisonSchemeDetailBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PackageInfoBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PackageInfoResAndBargBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PackageInfoResBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PackageOrdersBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PeriodPointBean;
import com.sgcc.sx.pmos.e_sx_order.bean.PriceDetailBean;
import com.sgcc.sx.pmos.e_sx_order.bean.ResultBargainBean;
import com.sgcc.sx.pmos.e_sx_order.bean.SchemeResBean;
import com.sgcc.sx.pmos.e_sx_order.contract.OrderDetailsContract;
import com.sgcc.sx.pmos.e_sx_order.presenter.OrderDetailsPresenter;
import com.sgcc.sx.pmos.e_sx_order.utils.OrderDetailsUtils;
import com.sgcc.sx.pmos.mobileapp.dialog.AccountIncrementPopup;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 订单详情
 */
@Route(path = OrderArouterPath.ORDER_ORDERDETAILS)
public class OrderDetailsActivity extends MvpBaseActivity<OrderDetailsPresenter> implements OrderDetailsContract.View {

    private static final String TAG = "OrderDetailsActivity";

    @Autowired
    public String from;

    @Autowired
    public String relCode;

    @Autowired
    public String updateDate;


    private RelativeLayout mRlCompanyNameLinks;
    private TextView mTvCompanyName;
    private ImageView mIvPackageLogo;
    private TextView mTvPackageName;
    private TextView mTvPackageTime;
    private TextView tv_order_hyzq;
    private TextView tv_copy;
    private TextView mTvPackageStatus;
    private TextView mTvOrderNumber;
    private TextView mTvOrderTime;
    private TextView mTvPackageYear;
    private RecyclerView mRlMonth;
    private TextView mTvYddlDl;
    private TextView tvMainPackageTitleName;
    private RelativeLayout mRlYddlBghDl;
    private RecyclerView mRlYdElectricity;
    private TextView mTvGoodsType;
    private TextView mTvLeftUserUpNumber;
    private RelativeLayout mRlRightUserUpNumber;
    private TextView mTvRightUserUpNumber;
    private TextView mTvLeftUserDownNumber;
    private RelativeLayout mRlRightUserDownNumber;
    private TextView mTvRightUserDownNumber;
    private LinearLayout mLlBasePackageTitle;
    private LinearLayout ll_bottom;
    private TextView mTvLeftIsPeriodTime;
    private RelativeLayout mRlRightIsPeriodTime;
    private TextView mTvRightIsPeriodTime;
    private TextView mTvLeftIsConventionPower;
    private TextView tvSingleTitleName;
    private RelativeLayout mRlRightIsConventionPower;
    private TextView mTvRightIsConventionPower;
    private TextView mTvLeftYxpcfw;
    private RelativeLayout mRlRightYxpcfw;
    private TextView mTvRightYxpcfw;
    private LinearLayout mLlContent;
    private LinearLayout mLlYddlOut;
    private LinearLayout mLlYddl;
    private TextView mTvLeftYddlYdjg;
    private TextView mTvLeftYddlYdjc;
    private TextView mTvLeftYddlGz;
    private RelativeLayout mRlRightYddl;
    private TextView mTvRightYddlYdjg;
    private TextView mTvRightYddlYdjc;
    private TextView mTvRightYddlGz;
    private LinearLayout mLlZpcdldjWai;
    private LinearLayout mLlZpcdldj;
    private TextView mTvLeftZpcdldjYdjg;
    private TextView mTvLeftZpcdldjGz;
    private RelativeLayout mRlRightZpcdldj;
    private TextView mTvRightZpcdldjYdjg;
    private TextView mTvRightZpcdldjGz;
    private LinearLayout mLlFpcdldjWai;
    private LinearLayout mLlFpcdldj;
    private TextView mTvLeftFpcdldjUp;
    private TextView mTvLeftFpcdldjDown;
    private RelativeLayout mRlRightFpcdldj;
    private TextView mTvRightFpcdldjUp;
    private TextView mTvRightFpcdldjDown;
    private TextView mTvFloatingLeftIsPeriodTime;
    private RelativeLayout mRlFloatingRightIsPeriodTime;
    private TextView mTvFloatingRightIsPeriodTime;
    private TextView mTvFloatingLeftIsConventionPower;
    private TextView tvFloTitleName;
    private RelativeLayout mRlFloatingRightIsConventionPower;
    private TextView mTvFloatingRightIsConventionPower;
    private TextView mTvFloatingLeftYxpcfw;
    private RelativeLayout mRlFloatingRightYxpcfw;
    private TextView mTvFloatingRightYxpcfw;
    private LinearLayout mLlFloatingContent;
    private LinearLayout mLlFloatingYddlOut;
    private LinearLayout mLlFloatingYddl;
    private TextView mTvFloatingLeftYddlYdjg;
    private TextView mTvFloatingLeftYddlYdjc;
    private TextView mTvFloatingLeftYddlGz;
    private RelativeLayout mRlFloatingRightYddl;
    private TextView mTvFloatingRightYddlYdjg;
    private TextView mTvFloatingRightYddlYdjc;
    private TextView mTvFloatingRightYddlGz;
    private LinearLayout mLlFloatingZpcdldjWai;
    private LinearLayout mLlFloatingZpcdldj;
    private TextView mTvFloatingLeftZpcdldjYdjg;
    private TextView mTvFloatingLeftZpcdldjGz;
    private RelativeLayout mRlFloatingRightZpcdldj;
    private TextView mTvFloatingRightZpcdldjYdjg;
    private TextView mTvFloatingRightZpcdldjGz;
    private LinearLayout mLlFloatingFpcdldjWai;
    private LinearLayout mLlFloatingFpcdldj;
    private LinearLayout ll_floating_right_fpcdldj;
    private LinearLayout ll_goods_content;
    private TextView mTvFloatingLeftFpcdldjUp;
    private TextView mTvFloatingLeftFpcdldjDown;
    private RelativeLayout mRlFloatingRightFpcdldj;
    private TextView mTvFloatingRightFpcdldjUp;
    private TextView mTvFloatingRightFpcdldjDown;
    private TextView tv_no_period_old_ele;
    private TextView tv_no_period_new_ele;
    private RelativeLayout rl_no_period_new_ele;
    private RelativeLayout mRlBgdj;
    private RelativeLayout mRlCxyj;
    private RelativeLayout mRlBhyj;
    private RelativeLayout mRlBgdl;
    private RelativeLayout mDjbgcx;
    private RelativeLayout mDlbgcx;
    private RelativeLayout mDjbgqr;
    private RelativeLayout mRlDjbgbh;
    private RelativeLayout mRlJchy;
    private RelativeLayout mRlLjqr;
    private RelativeLayout mRlZcgm;
    private RelativeLayout mRlHtxq;
    private RelativeLayout mRlLjpj;
    private RelativeLayout mRlHyjccx;
    private RelativeLayout rl_qxdd;
    private RelativeLayout rl_sqyj;
    private RelativeLayout rl_cxbabcxy, rl_bcxyqr, rl_babcxy;
    private RelativeLayout rl_packageId;
    private TitleBar mTitleBar;
    private SmartRefreshLayout mRefreshLayout;
    private LoadingLayout mLoadinglayout;
    private IndentOrContractBean mIndentOrContractBean;
    private MonthAdapter mMonthAdapter;
    private ConventionPowerAdapter mConventionPowerAdapter;
    private LinearLayout mLlYdEleNoPeriod, ll_yddl_title, ll_yddl_bgh_dl, ll_floating;
    private RelativeLayout mRlYdEle;
    private List<ContractElectricityBean> mList_ele;
    private TextView tv_left_zpcdldj_ydjc, tv_left_fpcdldj_ydjc, tv_floating_left_zpcdldj_ydjc, tv_floating_left_fpcdldj_ydjc,
            tv_right_zpcdldj_ydjc, tv_right_fpcdldj_ydjc, tv_floating_right_zpcdldj_ydjc, tv_floating_right_fpcdldj_ydjc;
    private List<PackageOrdersBean.DataBean> mPackageOrdersBeanList = new ArrayList<>();
    private boolean base_top = false;
    private boolean base_center = false;
    private boolean base_bottom = false;

    private boolean floating_top = false;
    private boolean floating_center = false;
    private boolean floating_bottom = false;
    private List<String> month_list = new ArrayList<>();
    private String mCurrentMonth = "";//当前月
    private List<PackageInfoBean.DataDTO> mPackageInfoList;
    private List<PeriodPointBean> mEnergyByMonthDetailList = new ArrayList<>();
    private boolean isClickMonth = false;
    private boolean isAddBottomBtn = false;//是否显示上传补充协议按钮
    private TextView tv_more;
    String[] btnlist = {"撤销备案补充协议", "补充协议确认", "补充协议", "合同详情", "变更电价", "撤销议价", "驳回议价", "变更电量", "电价变更撤销", "电量变更撤销", "电价变更确认", "电价变更驳回", "解除合约", "合约解除撤销", "立即确认", "再次购买", "立即评价", "取消订单", "申请议价"};
    List<String> btnArraylist = new ArrayList<>();
    List<String> btoomBtnArraylist = new ArrayList<>();
    List<String> finalList = new ArrayList<>();
    String targetYear = "";
    String userSelectTime = "";
    LinearLayout contract_month_status_linner;
    TextView contract_month_status;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_orderdetails;
    }

    @Override
    protected OrderDetailsPresenter createPresenter() {
        return new OrderDetailsPresenter();
    }

    @Override
    protected void initViews() {
        super.initViews();
        findViewByIds();
    }

    @Override
    protected void initData() {
        super.initData();
        mRefreshLayout.setEnableLoadMore(false);
        LinearLayoutManager mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
        mRlMonth.setLayoutManager(mLayoutManager);
        mRlMonth.setItemAnimator(new DefaultItemAnimator());
        mMonthAdapter = new MonthAdapter(mContext);
        mRlMonth.setAdapter(mMonthAdapter);


        mLoadinglayout.showContent();
        LinearLayoutManager mRlYdElectricityLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
        mRlYdElectricity.setLayoutManager(mRlYdElectricityLayoutManager);
        mRlYdElectricity.setItemAnimator(new DefaultItemAnimator());
        mConventionPowerAdapter = new ConventionPowerAdapter();
        mRlYdElectricity.setAdapter(mConventionPowerAdapter);
        setViewListener();
    }

    @Override
    public boolean isBindEventBusHere() {
        return true;
    }

    @Override
    public void onEventCallBack(EventCenter eventCenter) {
        if (eventCenter.getEventCode() == ArguConstant.INTERFACE_LOGOUT) {
            dismissLoading();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        showLoading();
//        if(TextUtils.isEmpty(mCurrentMonth)){
//            int month = Calendar.getInstance().get(Calendar.MONTH)+1;
//            if(month<10){
//                mCurrentMonth ="0"+month+"月";
//            }else{
//                mCurrentMonth =month+"月";
//            }
//        }
//        int month = Calendar.getInstance().get(Calendar.MONTH);
//        mMonthAdapter.setSelectPosition(month);
////        mCurrentMonth =month+"月";
////        mCurrentMonth ="03月";
        onRefreshPage("");
    }

    /**
     * 给控件设置监听
     */
    private void setViewListener() {
        tv_more.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showBtnPop(btnArraylist);
            }
        });


        //撤销备案补充协议
        rl_cxbabcxy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cxbcxy();
            }
        });
        //补充协议确认
        rl_bcxyqr.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                bcxyqr();
            }
        });
        //备案补充协议
        rl_babcxy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                bcxy();
            }
        });

        //合同详情
        mRlHtxq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                htxq();
            }
        });
        ll_goods_content.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mIndentOrContractBean != null) {
                    if (!TextUtils.isEmpty(mIndentOrContractBean.getCombCode())) {
                        ARouter.getInstance()
                                .build(MallArouterPath.MALL_PACKAGEDETAILS)
                                .withString("combName", mIndentOrContractBean.getCombCode())
                                .navigation();
                    } else {
                        ToastUtils.showShort("商品不存在或已下架");
                    }
                } else {
                    ToastUtils.showShort("商品不存在或已下架");
                }

            }
        });
        mMonthAdapter.setOnItemClickListener(new BaseRecyclerAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, Object data) {
                //点击事件
                mMonthAdapter.setSelectPosition(position);
                mCurrentMonth = (String) data;
                isClickMonth = true;
                userSelectTime = targetYear + "-" + mCurrentMonth.replace("月", "");
                showLoading();
                if ("1".equals(from)) {
                    on1Or2column(mIndentOrContractBean.getRelStatus(), mIndentOrContractBean.getModificationType(), mIndentOrContractBean.getmStatus());
                }
                mPresenter.getPackageInfo(mIndentOrContractBean.getCombId(), mIndentOrContractBean.getRelationId(),
                        mIndentOrContractBean.getStartDate(), mIndentOrContractBean.getEndDate());

            }
        });

        mRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                onRefreshPage("");
            }
        });

        mTitleBar.setRightIcon(R.mipmap.go_main, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                goMainActivity();
            }
        });

        mRlCompanyNameLinks.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance()
                        .build(MallArouterPath.MALL_STOREHOMEPAGE)
                        .withString("membersSdId", mIndentOrContractBean.getMembersSdId())
                        .navigation();
            }
        });

        mRlHyjccx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //合约接触撤销
                hyjccx();
            }
        });

        mRlBgdj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //变更电价
                bgdj();
            }
        });
        mRlCxyj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //撤销议价
                cxyj();
            }
        });
        mRlBhyj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //驳回议价
                bhyj();
            }
        });
        mRlBgdl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //变更电量
                bgdl();
            }
        });
        mDjbgcx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //电价变更撤销
                djbgcx();
            }
        });
        mDlbgcx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //电量变更撤销
                dlbgcx();
            }
        });
        mDjbgqr.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //电价变更确认
                djbgqr();
            }
        });
        mRlDjbgbh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //电价变更驳回
                djbgbh();
            }
        });
        mRlJchy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //解除合约
                jchy();
            }
        });
        mRlLjqr.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //立即确认
                mPresenter.beforeSubmit_check(mIndentOrContractBean.getRelationId());

//                mPresenter.orderCheck(mIndentOrContractBean.getRelationId(), mIndentOrContractBean.getMembersSdId(), mIndentOrContractBean.getCombId(),
//                        DateUtils.getStrng_to_Times_ymd_2(mIndentOrContractBean.getStartDate()), DateUtils.getStrng_to_Times_ymd_2(mIndentOrContractBean.getEndDate()));
            }
        });
        mRlZcgm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //再次购买
            }
        });
        mRlLjpj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //立即评价
            }
        });

        tv_copy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String orderNumber = mIndentOrContractBean.getRelCode();
                ClipboardUtils.copyText(orderNumber);
                ToastUtils.showShort("已经复制到剪贴板");
            }
        });

        rl_qxdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //取消订单
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.cancelOrder(relationId);

            }
        });
        rl_sqyj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //申请议价
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.applyForBargain(relationId);
            }
        });


    }

    private void setViewHeight() {
        mLlYddl.setPadding(10, 10, 10, 10);
        mLlYddl.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (!base_top) {
                    base_top = true;
                    // h就是TextView的高度,h就是TextView的宽度
                    int h = mLlYddl.getMeasuredHeight();
                    //为ImageView设置宽高
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mLlContent.getLayoutParams();
                    params.height = h;
                    mLlContent.setLayoutParams(params);
                }
            }
        });

        mLlZpcdldj.setPadding(10, 10, 10, 10);
        mLlZpcdldj.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (!base_center) {
                    base_center = true;
                    // h就是TextView的高度,h就是TextView的宽度
                    int h = mLlZpcdldj.getMeasuredHeight();
                    //为ImageView设置宽高
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ll_base_center.getLayoutParams();
                    params.height = h;
                    ll_base_center.setLayoutParams(params);

                }
            }
        });

        mLlFpcdldj.setPadding(10, 10, 10, 10);
        mLlFpcdldj.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (!base_bottom) {
                    base_bottom = true;
                    // h就是TextView的高度,h就是TextView的宽度
                    int h = mLlFpcdldj.getMeasuredHeight();
                    //为ImageView设置宽高
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ll_base_bottom.getLayoutParams();
                    params.height = h;
                    ll_base_bottom.setLayoutParams(params);
                }
            }
        });

        mLlFloatingYddl.setPadding(10, 10, 10, 10);
        mLlFloatingYddl.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (!floating_top) {
                    floating_top = true;
                    // h就是TextView的高度,h就是TextView的宽度
                    int h = mLlFloatingYddl.getMeasuredHeight();
                    //为ImageView设置宽高
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mLlFloatingContent.getLayoutParams();
                    params.height = h;
                    mLlFloatingContent.setLayoutParams(params);
                }
            }
        });

        mLlFloatingZpcdldj.setPadding(10, 10, 10, 10);
        mLlFloatingZpcdldj.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (!floating_center) {
                    floating_center = true;
                    // h就是TextView的高度,h就是TextView的宽度
                    int h = mLlFloatingZpcdldj.getMeasuredHeight();
                    //为ImageView设置宽高
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ll_floating_center.getLayoutParams();
                    params.height = h;
                    ll_floating_center.setLayoutParams(params);
                }
            }
        });

        mLlFloatingFpcdldj.setPadding(10, 10, 10, 10);
        ll_floating_right_fpcdldj.setPadding(10, 10, 10, 10);
        mLlFloatingFpcdldj.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (!floating_bottom) {
                    floating_bottom = true;
                    // h就是TextView的高度,h就是TextView的宽度
                    int h = mLlFloatingFpcdldj.getMeasuredHeight();
                    //为ImageView设置宽高
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ll_floating_bottom.getLayoutParams();
                    params.height = h;
                    ll_floating_bottom.setLayoutParams(params);
                }
            }
        });
    }

    /**
     * 刷新页面
     *
     * @param msg 状态改变时某个接口返回的message
     */
    private void onRefreshPage(String msg) {
        if (!TextUtils.isEmpty(msg)) {
            ToastUtils.showShort(msg);
        }
        mPresenter.getContractList(relCode, "1".equals(from) ? "0" : "1");
    }

    private void findViewByIds() {
        mTitleBar = (TitleBar) findViewById(R.id.title_bar);
        mRefreshLayout = (SmartRefreshLayout) findViewById(R.id.refreshLayout);
        mLoadinglayout = (LoadingLayout) findViewById(R.id.loadinglayout);

        mRlCompanyNameLinks = (RelativeLayout) findViewById(R.id.rl_company_name_links);
        mTvCompanyName = (TextView) findViewById(R.id.tv_company_name);
        mIvPackageLogo = (ImageView) findViewById(R.id.iv_package_logo);
        mTvPackageName = (TextView) findViewById(R.id.tv_package_name);
        mTvPackageTime = (TextView) findViewById(R.id.tv_package_time);
        tv_order_hyzq = (TextView) findViewById(R.id.tv_order_hyzq);
        tv_copy = (TextView) findViewById(R.id.tv_copy);
        mTvPackageStatus = (TextView) findViewById(R.id.tv_package_status);
        mTvOrderNumber = (TextView) findViewById(R.id.tv_order_number);
        mTvOrderTime = (TextView) findViewById(R.id.tv_order_time);
        mTvPackageYear = (TextView) findViewById(R.id.tv_package_year);
        mRlMonth = (RecyclerView) findViewById(R.id.rl_month);
        mTvYddlDl = (TextView) findViewById(R.id.tv_yddl_dl);
        tvMainPackageTitleName = (TextView) findViewById(R.id.tvMainPackageTitleName);
        mRlYddlBghDl = (RelativeLayout) findViewById(R.id.rl_yddl_bgh_dl);
        mRlYdElectricity = (RecyclerView) findViewById(R.id.rl_yd_electricity);
        mTvGoodsType = (TextView) findViewById(R.id.tv_goods_type);
        mTvLeftUserUpNumber = (TextView) findViewById(R.id.tv_left_user_up_number);
        mRlRightUserUpNumber = (RelativeLayout) findViewById(R.id.rl_right_user_up_number);
        mTvRightUserUpNumber = (TextView) findViewById(R.id.tv_right_user_up_number);
        mTvLeftUserDownNumber = (TextView) findViewById(R.id.tv_left_user_down_number);
        mRlRightUserDownNumber = (RelativeLayout) findViewById(R.id.rl_right_user_down_number);
        mTvRightUserDownNumber = (TextView) findViewById(R.id.tv_right_user_down_number);
        mLlBasePackageTitle = (LinearLayout) findViewById(R.id.ll_base_package_title);
        ll_goods_content = (LinearLayout) findViewById(R.id.ll_goods_content);
        mTvLeftIsPeriodTime = (TextView) findViewById(R.id.tv_left_is_period_time);
        mRlRightIsPeriodTime = (RelativeLayout) findViewById(R.id.rl_right_is_period_time);
        mTvRightIsPeriodTime = (TextView) findViewById(R.id.tv_right_is_period_time);
        mTvLeftIsConventionPower = (TextView) findViewById(R.id.tv_left_is_convention_power);
        tvSingleTitleName = (TextView) findViewById(R.id.tvSingleTitleName);
        mRlRightIsConventionPower = (RelativeLayout) findViewById(R.id.rl_right_is_convention_power);
        mTvRightIsConventionPower = (TextView) findViewById(R.id.tv_right_is_convention_power);
        mTvLeftYxpcfw = (TextView) findViewById(R.id.tv_left_yxpcfw);
        mRlRightYxpcfw = (RelativeLayout) findViewById(R.id.rl_right_yxpcfw);
        mTvRightYxpcfw = (TextView) findViewById(R.id.tv_right_yxpcfw);
        mLlContent = (LinearLayout) findViewById(R.id.ll_content);
        mLlFloatingContent = (LinearLayout) findViewById(R.id.ll_floating_content);
        ll_bottom = (LinearLayout) findViewById(R.id.ll_bottom);
        mLlYddlOut = (LinearLayout) findViewById(R.id.ll_yddl_out);
        mLlYddl = (LinearLayout) findViewById(R.id.ll_yddl);
        mTvLeftYddlYdjg = (TextView) findViewById(R.id.tv_left_yddl_ydjg);
        mTvLeftYddlYdjc = (TextView) findViewById(R.id.tv_left_yddl_ydjc);
        mTvLeftYddlGz = (TextView) findViewById(R.id.tv_left_yddl_gz);
        mRlRightYddl = (RelativeLayout) findViewById(R.id.rl_right_yddl);
        mTvRightYddlYdjg = (TextView) findViewById(R.id.tv_right_yddl_ydjg);
        mTvRightYddlYdjc = (TextView) findViewById(R.id.tv_right_yddl_ydjc);
        mTvRightYddlGz = (TextView) findViewById(R.id.tv_right_yddl_gz);
        mLlZpcdldjWai = (LinearLayout) findViewById(R.id.ll_zpcdldj_wai);
        mLlZpcdldj = (LinearLayout) findViewById(R.id.ll_zpcdldj);
        mTvLeftZpcdldjYdjg = (TextView) findViewById(R.id.tv_left_zpcdldj_ydjg);
        mTvLeftZpcdldjGz = (TextView) findViewById(R.id.tv_left_zpcdldj_gz);
        mRlRightZpcdldj = (RelativeLayout) findViewById(R.id.rl_right_zpcdldj);
        mTvRightZpcdldjYdjg = (TextView) findViewById(R.id.tv_right_zpcdldj_ydjg);
        mTvRightZpcdldjGz = (TextView) findViewById(R.id.tv_right_zpcdldj_gz);
        mLlFpcdldjWai = (LinearLayout) findViewById(R.id.ll_fpcdldj_wai);
        mLlFpcdldj = (LinearLayout) findViewById(R.id.ll_fpcdldj);
        mTvLeftFpcdldjUp = (TextView) findViewById(R.id.tv_left_fpcdldj_up);
        mTvLeftFpcdldjDown = (TextView) findViewById(R.id.tv_left_fpcdldj_down);
        mRlRightFpcdldj = (RelativeLayout) findViewById(R.id.rl_right_fpcdldj);
        mTvRightFpcdldjUp = (TextView) findViewById(R.id.tv_right_fpcdldj_up);
        mTvRightFpcdldjDown = (TextView) findViewById(R.id.tv_right_fpcdldj_down);
        mTvFloatingLeftIsPeriodTime = (TextView) findViewById(R.id.tv_floating_left_is_period_time);
        mRlFloatingRightIsPeriodTime = (RelativeLayout) findViewById(R.id.rl_floating_right_is_period_time);
        mTvFloatingRightIsPeriodTime = (TextView) findViewById(R.id.tv_floating_right_is_period_time);
        mTvFloatingLeftIsConventionPower = (TextView) findViewById(R.id.tv_floating_left_is_convention_power);
        tvFloTitleName = (TextView) findViewById(R.id.tvFloTitleName);
        mRlFloatingRightIsConventionPower = (RelativeLayout) findViewById(R.id.rl_floating_right_is_convention_power);
        mTvFloatingRightIsConventionPower = (TextView) findViewById(R.id.tv_floating_right_is_convention_power);
        mTvFloatingLeftYxpcfw = (TextView) findViewById(R.id.tv_floating_left_yxpcfw);
        mRlFloatingRightYxpcfw = (RelativeLayout) findViewById(R.id.rl_floating_right_yxpcfw);
        mTvFloatingRightYxpcfw = (TextView) findViewById(R.id.tv_floating_right_yxpcfw);
        mLlFloatingYddlOut = (LinearLayout) findViewById(R.id.ll_floating_yddl_out);
        mLlFloatingYddl = (LinearLayout) findViewById(R.id.ll_floating_yddl);
        mTvFloatingLeftYddlYdjg = (TextView) findViewById(R.id.tv_floating_left_yddl_ydjg);
        mTvFloatingLeftYddlYdjc = (TextView) findViewById(R.id.tv_floating_left_yddl_ydjc);
        mTvFloatingLeftYddlGz = (TextView) findViewById(R.id.tv_floating_left_yddl_gz);
        mRlFloatingRightYddl = (RelativeLayout) findViewById(R.id.rl_floating_right_yddl);
        mTvFloatingRightYddlYdjg = (TextView) findViewById(R.id.tv_floating_right_yddl_ydjg);
        mTvFloatingRightYddlYdjc = (TextView) findViewById(R.id.tv_floating_right_yddl_ydjc);
        mTvFloatingRightYddlGz = (TextView) findViewById(R.id.tv_floating_right_yddl_gz);
        mLlFloatingZpcdldjWai = (LinearLayout) findViewById(R.id.ll_floating_zpcdldj_wai);
        mLlFloatingZpcdldj = (LinearLayout) findViewById(R.id.ll_floating_zpcdldj);
        mTvFloatingLeftZpcdldjYdjg = (TextView) findViewById(R.id.tv_floating_left_zpcdldj_ydjg);
        mTvFloatingLeftZpcdldjGz = (TextView) findViewById(R.id.tv_floating_left_zpcdldj_gz);
        mRlFloatingRightZpcdldj = (RelativeLayout) findViewById(R.id.rl_floating_right_zpcdldj);
        mTvFloatingRightZpcdldjYdjg = (TextView) findViewById(R.id.tv_floating_right_zpcdldj_ydjg);
        mTvFloatingRightZpcdldjGz = (TextView) findViewById(R.id.tv_floating_right_zpcdldj_gz);
        mLlFloatingFpcdldjWai = (LinearLayout) findViewById(R.id.ll_floating_fpcdldj_wai);
        mLlFloatingFpcdldj = (LinearLayout) findViewById(R.id.ll_floating_fpcdldj);
        ll_floating_right_fpcdldj = (LinearLayout) findViewById(R.id.ll_floating_right_fpcdldj);
        mTvFloatingLeftFpcdldjUp = (TextView) findViewById(R.id.tv_floating_left_fpcdldj_up);
        mTvFloatingLeftFpcdldjDown = (TextView) findViewById(R.id.tv_floating_left_fpcdldj_down);
        mRlFloatingRightFpcdldj = (RelativeLayout) findViewById(R.id.rl_floating_right_fpcdldj);
        mTvFloatingRightFpcdldjUp = (TextView) findViewById(R.id.tv_floating_right_fpcdldj_up);
        mTvFloatingRightFpcdldjDown = (TextView) findViewById(R.id.tv_floating_right_fpcdldj_down);
        tv_left_zpcdldj_ydjc = (TextView) findViewById(R.id.tv_left_zpcdldj_ydjc);
        tv_left_fpcdldj_ydjc = (TextView) findViewById(R.id.tv_left_fpcdldj_ydjc);
        tv_floating_left_zpcdldj_ydjc = (TextView) findViewById(R.id.tv_floating_left_zpcdldj_ydjc);
        tv_floating_left_fpcdldj_ydjc = (TextView) findViewById(R.id.tv_floating_left_fpcdldj_ydjc);
        tv_right_zpcdldj_ydjc = (TextView) findViewById(R.id.tv_right_zpcdldj_ydjc);
        tv_right_fpcdldj_ydjc = (TextView) findViewById(R.id.tv_right_fpcdldj_ydjc);
        tv_floating_right_zpcdldj_ydjc = (TextView) findViewById(R.id.tv_floating_right_zpcdldj_ydjc);
        tv_floating_right_fpcdldj_ydjc = (TextView) findViewById(R.id.tv_floating_right_fpcdldj_ydjc);
        tv_no_period_old_ele = (TextView) findViewById(R.id.tv_no_period_old_ele);
        tv_no_period_new_ele = (TextView) findViewById(R.id.tv_no_period_new_ele);
        mLlYdEleNoPeriod = (LinearLayout) findViewById(R.id.ll_yd_ele_no_period);
        ll_yddl_title = (LinearLayout) findViewById(R.id.ll_yddl_title);
        ll_yddl_bgh_dl = (LinearLayout) findViewById(R.id.ll_yddl_bgh_dl);
        ll_floating = (LinearLayout) findViewById(R.id.ll_floating);
        mRlYdEle = (RelativeLayout) findViewById(R.id.rl_yd_ele);
        rl_no_period_new_ele = (RelativeLayout) findViewById(R.id.rl_no_period_new_ele);

        //底部按钮
        tv_more = findViewById(R.id.tv_more);
        mRlBgdj = (RelativeLayout) findViewById(R.id.rl_bgdj);
        mRlHtxq = (RelativeLayout) findViewById(R.id.rl_htxq);
        mRlCxyj = (RelativeLayout) findViewById(R.id.rl_cxyj);
        mRlBhyj = (RelativeLayout) findViewById(R.id.rl_bhyj);
        mRlBgdl = (RelativeLayout) findViewById(R.id.rl_bgdl);
        mDjbgcx = (RelativeLayout) findViewById(R.id.djbgcx);
        mDlbgcx = (RelativeLayout) findViewById(R.id.dlbgcx);
        mDjbgqr = (RelativeLayout) findViewById(R.id.djbgqr);
        mRlDjbgbh = (RelativeLayout) findViewById(R.id.rl_djbgbh);
        mRlJchy = (RelativeLayout) findViewById(R.id.rl_jchy);
        mRlLjqr = (RelativeLayout) findViewById(R.id.rl_ljqr);
        mRlZcgm = (RelativeLayout) findViewById(R.id.rl_zcgm);
        mRlLjpj = (RelativeLayout) findViewById(R.id.rl_ljpj);
        mRlHyjccx = (RelativeLayout) findViewById(R.id.rl_hyjccx);


        rl_qxdd = (RelativeLayout) findViewById(R.id.rl_qxdd);
        rl_sqyj = (RelativeLayout) findViewById(R.id.rl_sqyj);
        rl_packageId = (RelativeLayout) findViewById(R.id.rl_packageId);

        rl_cxbabcxy = (RelativeLayout) findViewById(R.id.rl_cxbabcxy);
        rl_bcxyqr = (RelativeLayout) findViewById(R.id.rl_bcxyqr);
        rl_babcxy = (RelativeLayout) findViewById(R.id.rl_babcxy);


        ll_base_center = (LinearLayout) findViewById(R.id.ll_base_center);
        ll_base_bottom = (LinearLayout) findViewById(R.id.ll_base_bottom);

        ll_floating_center = (LinearLayout) findViewById(R.id.ll_floating_center);
        ll_floating_bottom = (LinearLayout) findViewById(R.id.ll_floating_bottom);

        contract_month_status_linner = (LinearLayout) findViewById(R.id.contract_month_status_linner);
        contract_month_status = findViewById(R.id.contract_month_status);

    }

    private LinearLayout ll_base_center, ll_base_bottom, ll_floating_center, ll_floating_bottom;

    @Override
    public void getEnergyByMonthDetail(EnergyByMonthDetailBean response, boolean isFirst) {
        if (response.getData() != null) {
            if ("200".equals(response.getCode())) {
                if (response.getData().isEmpty()) {
                    //不显示约定电量
                    ll_yddl_title.setVisibility(View.GONE);
                    mRlYdEle.setVisibility(View.GONE);
                } else {
                    mEnergyByMonthDetailList = response.getData();
                    //显示约定电量
                    //判断是否是分时段 约定电量
                    String peType = OrderDetailsUtils.getGoodsType(OrderDetailsUtils.getBeanByPackageInfo(mCurrentMonth, mPackageInfoList).getMainType(),
                            OrderDetailsUtils.getBeanByPackageInfo(mCurrentMonth, mPackageInfoList).getFloType()); //分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04

                    //判断约定电量的值是否两行
                    if ("3".equals(mIndentOrContractBean.getRelStatus()) && "202".equals(mIndentOrContractBean.getModificationType()) && "102".equals(mIndentOrContractBean.getmStatus())) {
                        //已生效   电量变更    待售电公司确认         约定电量是两行
                        mRlYddlBghDl.setVisibility(View.VISIBLE);
                        ll_yddl_bgh_dl.setVisibility(View.VISIBLE);
                        mPresenter.queryOrderInfoOfTable(mIndentOrContractBean.getRelCode(),
                                OrderDetailsUtils.getBeanByEnergyByMonthDetailList(mCurrentMonth, mEnergyByMonthDetailList).getMonthDate(), peType);
                    } else {
                        //约定电量是一行
                        mRlYddlBghDl.setVisibility(View.GONE);
                        ll_yddl_bgh_dl.setVisibility(View.GONE);
                        if ("01".equals(peType) || "02".equals(peType)) {
                            PeriodPointBean sss = OrderDetailsUtils.getBeanByEnergyByMonthDetailList(mCurrentMonth, mEnergyByMonthDetailList);
                            List<String> list = OrderDetailsUtils.getFieldValue(sss);
                            //获取电量
                            mList_ele = new ArrayList<>();
                            BigDecimal total = BigDecimal.ZERO;

                            if (null != list) {
                                for (int i = 0; i < list.size(); i++) {
                                    ContractElectricityBean bean = new ContractElectricityBean();
                                    bean.setPeriod((i + 1) + "");
                                    bean.setOld_ele(list.get(i));
                                    mList_ele.add(bean);

                                    total = BigDecimalUtils.add(total, new BigDecimal(list.get(i)));
                                }
                            }

                            ContractElectricityBean bean = new ContractElectricityBean();
                            bean.setPeriod("总");
                            BigDecimal result = total.setScale(2, BigDecimal.ROUND_HALF_UP);
                            bean.setOld_ele(result.stripTrailingZeros().toPlainString());
                            mList_ele.add(0, bean);

                            mConventionPowerAdapter.setNewData(mList_ele);
                        } else if ("03".equals(peType)) {
                            mLlYdEleNoPeriod.setVisibility(View.VISIBLE);
                            rl_no_period_new_ele.setVisibility(View.GONE);
                            tv_no_period_old_ele.setText(BigDecimalUtils.onKeep3Decimal(
                                    OrderDetailsUtils.getBeanByEnergyByMonthDetailList(mCurrentMonth, mEnergyByMonthDetailList).getEnergy0()));
                        } else {

                        }
                    }
                }

                if ("1".equals(from)) {//1为订单 2为合约
                    //类型为订单时，变更状态为议价203，订单状态待确认1，审核状态售电公司已确认104
                    on1Or2column(mIndentOrContractBean.getRelStatus(), mIndentOrContractBean.getModificationType(), mIndentOrContractBean.getmStatus());
                } else {
                    //调用合约下拉 接口 来获取每个月的变更状态  审核状态
                    mPresenter.getPackageOrders(mIndentOrContractBean.getRelationId());
                }
            }
        }
    }

    @Override
    public void queryOrderInfoOfTable(OrderInfoOfTableBean response, String peType) {
        if (response.getData() != null) {
            if (!response.getData().isEmpty()) {
                if ("01".equals(peType) || "02".equals(peType)) {
                    List<String> list = OrderDetailsUtils.getFieldValue(response.getData().get(0));
                    //获取电量

                    //老的
                    mList_ele = new ArrayList<>();
                    BigDecimal total = BigDecimal.ZERO;

                    //新的
                    String json = response.getData().get(0).getMcontent();
                    if (TextUtils.isEmpty(json)) {
                        //约定电量是一行
                        mRlYddlBghDl.setVisibility(View.GONE);
                        ll_yddl_bgh_dl.setVisibility(View.GONE);
                        if ("01".equals(peType) || "02".equals(peType)) {

                            for (int i = 0; i < list.size(); i++) {
                                ContractElectricityBean bean = new ContractElectricityBean();
                                bean.setPeriod((i + 1) + "");
                                bean.setOld_ele(list.get(i));
                                mList_ele.add(bean);

                                total = BigDecimalUtils.add(total, new BigDecimal(list.get(i)));

                            }

                            ContractElectricityBean bean = new ContractElectricityBean();
                            bean.setPeriod("总");
                            BigDecimal result = total.setScale(2, BigDecimal.ROUND_HALF_UP);
                            bean.setOld_ele(result.stripTrailingZeros().toPlainString());
                            mList_ele.add(0, bean);

                            mConventionPowerAdapter.setNewData(mList_ele);
                        } else if ("03".equals(peType)) {
                            mLlYdEleNoPeriod.setVisibility(View.VISIBLE);
                            rl_no_period_new_ele.setVisibility(View.GONE);
                            tv_no_period_old_ele.setText(BigDecimalUtils.onKeep3Decimal(response.getData().get(0).getEnergy0()));
                        } else {

                        }
                    } else {
                        OrderTableBean orderTableBean = GsonUtils.fromJson(json, OrderTableBean.class);
                        List<String> list_new = OrderDetailsUtils.getFieldValue(orderTableBean);
                        BigDecimal total_new = BigDecimal.ZERO;
                        if (null != list) {
                            for (int i = 0; i < list.size(); i++) {
                                ContractElectricityBean bean = new ContractElectricityBean();
                                bean.setPeriod((i + 1) + "");
                                bean.setOld_ele(list.get(i));
                                bean.setNew_ele(list_new == null ? "0" : list_new.get(i));
                                mList_ele.add(bean);

                                total = BigDecimalUtils.add(total, new BigDecimal(list.get(i)));
                                total_new = BigDecimalUtils.add(total_new, new BigDecimal(list_new == null ? "0" : list_new.get(i)));
                            }
                        }
                        ContractElectricityBean bean = new ContractElectricityBean();
                        bean.setPeriod("总");
                        BigDecimal result = total.setScale(2, BigDecimal.ROUND_HALF_UP);
                        bean.setOld_ele(result.stripTrailingZeros().toPlainString());

                        BigDecimal result_new = total_new.setScale(2, BigDecimal.ROUND_HALF_UP);
                        bean.setNew_ele(result_new.stripTrailingZeros().toPlainString());
                        mList_ele.add(0, bean);

                        mConventionPowerAdapter.setNewData(mList_ele);
                    }
                } else if ("03".equals(peType)) {
                    //新的
                    String json = response.getData().get(0).getMcontent();
                    OrderTableBean orderTableBean = GsonUtils.fromJson(json, OrderTableBean.class);
                    tv_no_period_old_ele.setText(response.getData().get(0).getEnergy0());
                    tv_no_period_new_ele.setText(BigDecimalUtils.onKeep3Decimal(orderTableBean.getEnergy0()));
                } else {

                }
            }
        }
    }

    @Override
    public void getPackageOrders(PackageOrdersBean response) {
        if (response.getData() != null) {
            if (!response.getData().isEmpty()) {
                mPackageOrdersBeanList = response.getData();
                PackageOrdersBean.DataBean bean = OrderDetailsUtils.getPackageOrdersBean(mCurrentMonth, mPackageOrdersBeanList);
                if (bean != null) {
                    changePlayBottomBtn(bean.getRelStatus(), bean.getModificationType(), bean.getMStatus(), bean.isPowerChange(), bean.isPriceChange());
                    on1Or2column(bean.getRelStatus(), bean.getModificationType(), bean.getMStatus());
                } else {
                    ll_bottom.setVisibility(View.GONE);
                    mRlBgdj.setVisibility(View.GONE);
                    mRlCxyj.setVisibility(View.GONE);
                    mRlBhyj.setVisibility(View.GONE);
                    mRlBgdl.setVisibility(View.GONE);
                    mDjbgcx.setVisibility(View.GONE);
                    mDlbgcx.setVisibility(View.GONE);
                    mDjbgqr.setVisibility(View.GONE);
                    mRlDjbgbh.setVisibility(View.GONE);
                    mRlJchy.setVisibility(View.GONE);
                    mRlLjqr.setVisibility(View.GONE);
                    mRlHyjccx.setVisibility(View.GONE);
                    mRlZcgm.setVisibility(View.GONE);
                    mRlLjpj.setVisibility(View.GONE);
                    dismissLoading();
                    mRefreshLayout.finishRefresh();
                }
            }
        }
    }

    @Override
    public void getPackageInfo(PackageInfoBean response) {
        if (response.getData() != null) {
            if (!response.getData().isEmpty()) {
                mPackageInfoList = response.getData();
                month_list.clear();
                //获取月份信息
                for(int i=0;i<response.getData().size();i++){
//                    PackageInfoBean.DataDTO dataDTO=new PackageInfoBean.DataDTO();
                    String monthDate = response.getData().get(i).getMonthDate();
                    if (!TextUtils.isEmpty(monthDate)) {
                        String month = DateUtils.getStrng_to_Times_ymd_4_1(monthDate);
                        month_list.add(month + "月");
                    }

                    if(TextUtils.isEmpty(mCurrentMonth)){
                        String tarketTime=    DateUtils.getStrng_to_Times_ymd_3(monthDate);
                        String nowTime=  TimeUtils.date2String(TimeUtils.getNowDate(),"yyyy-MM");
                        if(TextUtils.equals(tarketTime,nowTime)){
//                            if(month<10){
//                                mCurrentMonth ="0"+month+1+"月";
//                            }else{
//                                mCurrentMonth =month+"月";
//                            }
                            mCurrentMonth=month_list.get(i);
                            mMonthAdapter.setSelectPosition(i);
                        }
                    }

                }
//                for (PackageInfoBean.DataDTO dataDTO : response.getData()) {
//                    String monthDate = dataDTO.getMonthDate();
//                    if (!TextUtils.isEmpty(monthDate)) {
//                        String month = DateUtils.getStrng_to_Times_ymd_4_1(monthDate);
//                        month_list.add(month + "月");
//                    }
//                }




                mTvPackageYear.setText(DateUtils.getStrng_to_Times_y(response.getData().get(0).getMonthDate()));
                targetYear = mTvPackageYear.getText().toString().replace("年", "");
                if (TextUtils.isEmpty(mCurrentMonth)) {
                    mCurrentMonth = DateUtils.getStrng_to_Times_ymd_4_1(response.getData().get(0).getMonthDate());
                }

                PackageInfoBean.DataDTO dataDTO = OrderDetailsUtils.getBeanByPackageInfo(mCurrentMonth, mPackageInfoList);
                String peType = "";//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                if ("1".equals(dataDTO.getpNum())) {//单一套餐：1/组合套餐：2
                    peType = dataDTO.getMainType();
                } else {
                    peType = OrderDetailsUtils.getGoodsType(dataDTO.getMainType(), dataDTO.getFloType());
                }
                switch (peType) {
                    case "01":
                        mLlYdEleNoPeriod.setVisibility(View.GONE);
                        mRlYdElectricity.setVisibility(View.VISIBLE);
                        break;
                    case "02":
                    case "04":
                        ll_yddl_title.setVisibility(View.GONE);
                        mRlYdEle.setVisibility(View.GONE);
                        break;
                    case "03":
                        mLlYdEleNoPeriod.setVisibility(View.VISIBLE);
                        mRlYdElectricity.setVisibility(View.GONE);
                        break;
                }

                mMonthAdapter.addDatas(month_list);


//                if(TextUtils.isEmpty(mCurrentMonth)){
//                    DateUtils
//                    int month = Calendar.getInstance().get(Calendar.MONTH)+1;
//                    if(month<10){
//                        mCurrentMonth ="0"+month+1+"月";
//                    }else{
//                        mCurrentMonth =month+"月";
//                    }
//                }
//                int month = Calendar.getInstance().get(Calendar.MONTH);
//                mMonthAdapter.setSelectPosition(month);


                String result = "";
                if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
                    result = "基础价格套餐";
                } else {
                    result = "组合套餐(基准套餐+浮动套餐)";
                }
                mTvGoodsType.setText(result);
                tvMainPackageTitleName.setText("1".equals(mIndentOrContractBean.getpNum()) ? "基础价格套餐参数" : "基准套餐参数");

                //查约定电量
                mPresenter.getEnergyByMonthDetail(mIndentOrContractBean.getRelationId(),
                        OrderDetailsUtils.getBeanByPackageInfo(mCurrentMonth, mPackageInfoList).getPackageId(), true);
            } else {
                dismissLoading();
                mRefreshLayout.finishRefresh();
            }
        }
    }

    @Override
    public void packageComparisonPriceDetailTwo(PackageComparisonPriceDetailBean response, boolean isMain) {
        if (response.getData() != null) {
            if (!response.getData().getResult().isEmpty()) {
                //调整前
                if (isMain) {
                    //基准/单一
                    for (PackageComparisonPriceDetailBean.DataBean.ResultBean bean : response.getData().getResult()) {
                        // energyType  数据位置（01约定电量，02正偏差电量电价，03负偏差电量电价）
                        if ("01".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                mTvLeftYddlYdjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                mTvLeftYddlYdjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvLeftYddlGz.setText(result);
                                mTvLeftYddlGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("02".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_left_zpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_left_zpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvLeftZpcdldjGz.setText(result);
                                mTvLeftZpcdldjGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("03".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_left_fpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_left_fpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvLeftFpcdldjDown.setText(result);
                                mTvLeftFpcdldjDown.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                    }
                } else {
                    //浮动
                    for (PackageComparisonPriceDetailBean.DataBean.ResultBean bean : response.getData().getResult()) {
                        // energyType  数据位置（01约定电量，02正偏差电量电价，03负偏差电量电价）
                        if ("01".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                mTvFloatingLeftYddlYdjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                mTvFloatingLeftYddlYdjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingLeftYddlGz.setText(result);
                                mTvFloatingLeftYddlGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("02".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_floating_left_zpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_floating_left_zpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingLeftZpcdldjGz.setText(result);
                                mTvFloatingLeftZpcdldjGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("03".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_floating_left_fpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_floating_left_fpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingLeftFpcdldjDown.setText(result);
                                mTvFloatingLeftFpcdldjDown.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                    }
                }
            }
            if (!response.getData().getBargain().isEmpty()) {
                //调整后
                if (isMain) {
                    //基准/单一
                    for (PackageComparisonPriceDetailBean.DataBean.BargainBean bean : response.getData().getBargain()) {
                        // energyType  数据位置（01约定电量，02正偏差电量电价，03负偏差电量电价）
                        if ("01".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                mTvRightYddlYdjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));

                                String oldStr = mTvLeftYddlYdjc.getText().toString().trim();
                                String newStr = mTvRightYddlYdjc.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvRightYddlYdjc.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), 5, mTvRightYddlYdjc.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvRightYddlYdjc.setText(span);
                                }

                                mTvRightYddlYdjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvRightYddlGz.setText(result);

                                String oldStr = mTvLeftYddlGz.getText().toString().trim();
                                String newStr = mTvRightYddlGz.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvRightYddlGz.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), bean.getConfigName().length(), mTvRightYddlGz.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvRightYddlGz.setText(span);
                                }


                                mTvRightYddlGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("02".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_right_zpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));

                                String oldStr = tv_left_zpcdldj_ydjc.getText().toString().trim();
                                String newStr = tv_right_zpcdldj_ydjc.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(tv_right_zpcdldj_ydjc.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), 5, tv_right_zpcdldj_ydjc.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    tv_right_zpcdldj_ydjc.setText(span);
                                }

                                tv_right_zpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvRightZpcdldjGz.setText(result);

                                String oldStr = mTvLeftZpcdldjGz.getText().toString().trim();
                                String newStr = mTvRightZpcdldjGz.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvRightZpcdldjGz.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), bean.getConfigName().length(), mTvRightZpcdldjGz.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvRightZpcdldjGz.setText(span);
                                }

                                mTvRightZpcdldjGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("03".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_right_fpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));

                                String oldStr = tv_left_fpcdldj_ydjc.getText().toString().trim();
                                String newStr = tv_right_fpcdldj_ydjc.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(tv_right_fpcdldj_ydjc.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), 5, tv_right_fpcdldj_ydjc.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    tv_right_fpcdldj_ydjc.setText(span);
                                }

                                tv_right_fpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvRightFpcdldjDown.setText(result);

                                String oldStr = mTvLeftFpcdldjDown.getText().toString().trim();
                                String newStr = mTvRightFpcdldjDown.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvRightFpcdldjDown.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), bean.getConfigName().length(), mTvRightFpcdldjDown.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvRightFpcdldjDown.setText(span);
                                }

                                mTvRightFpcdldjDown.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                    }
                } else {
                    //浮动
                    for (PackageComparisonPriceDetailBean.DataBean.BargainBean bean : response.getData().getBargain()) {
                        // energyType  数据位置（01约定电量，02正偏差电量电价，03负偏差电量电价）
                        if ("01".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                mTvFloatingRightYddlYdjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));

                                String oldStr = mTvFloatingLeftYddlYdjc.getText().toString().trim();
                                String newStr = mTvFloatingRightYddlYdjc.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvFloatingRightYddlYdjc.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), 5, mTvFloatingRightYddlYdjc.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvFloatingRightYddlYdjc.setText(span);
                                }


                                mTvFloatingRightYddlYdjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingRightYddlGz.setText(result);

                                String oldStr = mTvFloatingLeftYddlGz.getText().toString().trim();
                                String newStr = mTvFloatingRightYddlGz.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvFloatingRightYddlGz.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), bean.getConfigName().length(), mTvFloatingRightYddlGz.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvFloatingRightYddlGz.setText(span);
                                }

                                mTvFloatingRightYddlGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("02".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_floating_right_zpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));

                                String oldStr = tv_floating_left_zpcdldj_ydjc.getText().toString().trim();
                                String newStr = tv_floating_right_zpcdldj_ydjc.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(tv_floating_right_zpcdldj_ydjc.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), 5, tv_floating_right_zpcdldj_ydjc.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    tv_floating_right_zpcdldj_ydjc.setText(span);
                                }

                                tv_floating_right_zpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingRightZpcdldjGz.setText(result);

                                String oldStr = mTvFloatingLeftZpcdldjGz.getText().toString().trim();
                                String newStr = mTvFloatingRightZpcdldjGz.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvFloatingRightZpcdldjGz.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), bean.getConfigName().length(), mTvFloatingRightZpcdldjGz.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvFloatingRightZpcdldjGz.setText(span);
                                }

                                mTvFloatingRightZpcdldjGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("03".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_floating_right_fpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));

                                String oldStr = tv_floating_left_fpcdldj_ydjc.getText().toString().trim();
                                String newStr = tv_floating_right_fpcdldj_ydjc.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(tv_floating_right_fpcdldj_ydjc.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), 5, tv_floating_right_fpcdldj_ydjc.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    tv_floating_right_fpcdldj_ydjc.setText(span);
                                }

                                tv_floating_right_fpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingRightFpcdldjDown.setText(result);

                                String oldStr = mTvFloatingLeftFpcdldjDown.getText().toString().trim();
                                String newStr = mTvFloatingRightFpcdldjDown.getText().toString().trim();
                                if (!oldStr.equals(newStr)) {
                                    SpannableString span = new SpannableString(mTvFloatingRightFpcdldjDown.getText().toString());
                                    span.setSpan(new ForegroundColorSpan(Color.parseColor("#FFA500")), bean.getConfigName().length(), mTvFloatingRightFpcdldjDown.getText().toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                    mTvFloatingRightFpcdldjDown.setText(span);
                                }

                                mTvFloatingRightFpcdldjDown.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                    }
                }
            }

            if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                mPresenter.packageComparisonSchemeDetailTwo(schemeId, mIndentOrContractBean.getRelationId(), true);
            } else {
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                String floSchemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, false, mPackageInfoList);

                if (isMain) {
                    mPresenter.packageComparisonPriceDetailTwo(floSchemeId, mIndentOrContractBean.getRelationId(), false);
                } else {
                    mPresenter.packageComparisonSchemeDetailTwo(schemeId, mIndentOrContractBean.getRelationId(), true);
                }
            }
        }
    }

    @Override
    public void packageComparisonSchemeDetailTwo(PackageComparisonSchemeDetailBean response, boolean isMain) {
        if (response.getData() != null) {
            if (!response.getData().getResult().isEmpty()) {
                //调整前
                if (isMain) {
                    //基准/单一
                    if (response.getData().getResult().size() > 0) {
                        ResultBargainBean bean = response.getData().getResult().get(0);
                        // 分时段 分电量
                        String peType = bean.getPeType();//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                        switch (peType) {
                            case "01":
                                mTvLeftIsPeriodTime.setText("√");
                                mTvLeftIsConventionPower.setText("√");
                                tvSingleTitleName.setText("约定电量电价参数");
                                break;
                            case "02":
                                mTvLeftIsPeriodTime.setText("√");
                                mTvLeftIsConventionPower.setText("x");
                                tvSingleTitleName.setText("用电量电价参数");
                                break;
                            case "03":
                                mTvLeftIsPeriodTime.setText("x");
                                mTvLeftIsConventionPower.setText("√");
                                tvSingleTitleName.setText("约定电量电价参数");
                                break;
                            case "04":
                                mTvLeftIsPeriodTime.setText("x");
                                mTvLeftIsConventionPower.setText("x");
                                tvSingleTitleName.setText("用电量电价参数");
                                break;
                        }

                        //允许免偏差范围
                        String plRange = TextUtils.isEmpty(bean.getPlRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getPlRange()) + "%";//正允许免偏差范围(百分比)
                        String ndRange = TextUtils.isEmpty(bean.getNdRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getNdRange()) + "%";//负允许免偏差范围(百分比)
                        String range = "";
                        if (("--".equals(plRange) && "--".equals(ndRange))) {
                            range = "--";
                        } else {
                            range = ("--".equals(ndRange) ? "" : "-" + ndRange) + "  ~  " + ("--".equals(plRange) ? "" : plRange);

                        }
                        mTvLeftYxpcfw.setText(range);

                        //约定电量 / 计量电量电价名称
                        String eItemId = bean.geteItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvLeftYddlYdjg, "1", eItemId, peType, bean.geteItemName(), bean.geteItemValue(),
                                null, null, response.getData().getResult(), null);

                        //正偏差电量电价名称
                        String plItemId = bean.getPlItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvLeftZpcdldjYdjg, "2", plItemId, peType, bean.getPlItemName(), bean.getPlItemValue(),
                                null, null, response.getData().getResult(), null);

                        //负偏差电量电价名称
                        String ndItemId = bean.getNdItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvLeftFpcdldjUp, "3", ndItemId, peType, bean.getNdItemName(), bean.getNdItemValue(),
                                null, null, response.getData().getResult(), null);

                    }
                } else {
                    //浮动
                    if (response.getData().getResult().size() > 0) {
                        ResultBargainBean bean = response.getData().getResult().get(0);
                        // 分时段 分电量
                        String peType = bean.getPeType();//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                        switch (peType) {
                            case "01":
                                mTvFloatingLeftIsPeriodTime.setText("√");
                                mTvFloatingLeftIsConventionPower.setText("√");
                                tvFloTitleName.setText("约定电量电价参数");
                                break;
                            case "02":
                                mTvFloatingLeftIsPeriodTime.setText("√");
                                mTvFloatingLeftIsConventionPower.setText("x");
                                tvFloTitleName.setText("用电量电价参数");
                                break;
                            case "03":
                                mTvFloatingLeftIsPeriodTime.setText("x");
                                mTvFloatingLeftIsConventionPower.setText("√");
                                tvFloTitleName.setText("约定电量电价参数");
                                break;
                            case "04":
                                mTvFloatingLeftIsPeriodTime.setText("x");
                                mTvFloatingLeftIsConventionPower.setText("x");
                                tvFloTitleName.setText("用电量电价参数");
                                break;
                        }
                        //允许免偏差范围
                        String plRange = TextUtils.isEmpty(bean.getPlRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getPlRange()) + "%";//正允许免偏差范围(百分比)
                        String ndRange = TextUtils.isEmpty(bean.getNdRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getNdRange()) + "%";//负允许免偏差范围(百分比)
                        String range = "";
                        if (("--".equals(plRange) && "--".equals(ndRange))) {
                            range = "--";
                        } else {
                            range = ("--".equals(ndRange) ? "" : "-" + ndRange) + "  ~  " + ("--".equals(plRange) ? "" : plRange);

                        }
                        mTvFloatingLeftYxpcfw.setText(range);

                        //约定电量 / 计量电量电价名称
                        String eItemId = bean.geteItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingLeftYddlYdjg, "1", eItemId, peType, bean.geteItemName(), bean.geteItemValue(),
                                null, null, response.getData().getResult(), null);

                        //正偏差电量电价名称
                        String plItemId = bean.getPlItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingLeftZpcdldjYdjg, "2", plItemId, peType, bean.getPlItemName(), bean.getPlItemValue(),
                                null, null, response.getData().getResult(), null);

                        //负偏差电量电价名称
                        String ndItemId = bean.getNdItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingLeftFpcdldjUp, "3", ndItemId, peType, bean.getNdItemName(), bean.getNdItemValue(),
                                null, null, response.getData().getResult(), null);

                    }
                }
            }

            if (!response.getData().getBargain().isEmpty()) {
                //调整后
                if (isMain) {
                    //基准/单一
                    if (response.getData().getBargain().size() > 0) {
                        ResultBargainBean bean = response.getData().getBargain().get(0);
                        String peType = bean.getPeType();//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                        switch (peType) {
                            case "01":
                                if ("01".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvRightIsPeriodTime.setText("√");
                                mTvRightIsConventionPower.setText("√");
                                break;
                            case "02":
                                if ("02".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvRightIsPeriodTime.setText("√");
                                mTvRightIsConventionPower.setText("x");
                                break;
                            case "03":
                                if ("03".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvRightIsPeriodTime.setText("x");
                                mTvRightIsConventionPower.setText("√");
                                break;
                            case "04":
                                if ("04".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvRightIsPeriodTime.setText("x");
                                mTvRightIsConventionPower.setText("x");
                                break;
                        }

                        String plRange = TextUtils.isEmpty(bean.getPlRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getPlRange()) + "%";//正允许免偏差范围(百分比)
                        String ndRange = TextUtils.isEmpty(bean.getNdRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getNdRange()) + "%";//负允许免偏差范围(百分比)
                        String range = "";
                        if (("--".equals(plRange) && "--".equals(ndRange))) {
                            range = "--";
                        } else {
                            range = ("--".equals(ndRange) ? "" : "-" + ndRange) + "  ~  " + ("--".equals(plRange) ? "" : plRange);

                        }
                        mTvRightYxpcfw.setText(range);

                        String range1 = mTvLeftYxpcfw.getText().toString().trim();
                        if (range1.equals(range)) {
                            mTvRightYxpcfw.setTextColor(Color.parseColor("#333333"));
                        } else {
                            mTvRightYxpcfw.setTextColor(Color.parseColor("#FFA500"));
                        }

                        //约定电量 / 计量电量电价名称
                        String eItemId = bean.geteItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        ResultBargainBean bean_new = response.getData().getResult().get(0);
                        OrderDetailsUtils.setViewData(mTvRightYddlYdjg, "1", eItemId, peType, bean.geteItemName(), bean.geteItemValue(),
                                bean_new.geteItemName(), bean_new.geteItemValue(), response.getData().getBargain(), response.getData().getResult());

                        //正偏差电量电价名称
                        String plItemId = bean.getPlItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvRightZpcdldjYdjg, "2", plItemId, peType, bean.getPlItemName(), bean.getPlItemValue(),
                                bean_new.getPlItemName(), bean_new.getPlItemValue(), response.getData().getBargain(), response.getData().getResult());

                        //负偏差电量电价名称
                        String ndItemId = bean.getNdItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvRightFpcdldjUp, "3", ndItemId, peType, bean.getNdItemName(), bean.getNdItemValue(),
                                bean_new.getNdItemName(), bean_new.getNdItemValue(), response.getData().getBargain(), response.getData().getResult());

                    }
                } else {
                    //浮动
                    if (response.getData().getBargain().size() > 0) {
                        ResultBargainBean bean = response.getData().getBargain().get(0);
                        String peType = bean.getPeType();//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                        switch (peType) {
                            case "01":
                                if ("01".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvFloatingRightIsPeriodTime.setText("√");
                                mTvFloatingRightIsConventionPower.setText("√");
                                break;
                            case "02":
                                if ("02".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvFloatingRightIsPeriodTime.setText("√");
                                mTvFloatingRightIsConventionPower.setText("x");
                                break;
                            case "03":
                                if ("03".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvFloatingRightIsPeriodTime.setText("x");
                                mTvFloatingRightIsConventionPower.setText("√");
                                break;
                            case "04":
                                if ("04".equals(response.getData().getResult().get(0).getPeType())) {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#333333"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#333333"));
                                } else {
                                    mTvFloatingRightIsPeriodTime.setTextColor(Color.parseColor("#FFA500"));
                                    mTvFloatingRightIsConventionPower.setTextColor(Color.parseColor("#FFA500"));
                                }
                                mTvFloatingRightIsPeriodTime.setText("x");
                                mTvFloatingRightIsConventionPower.setText("x");
                                break;
                        }

                        String plRange = TextUtils.isEmpty(bean.getPlRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getPlRange()) + "%";//正允许免偏差范围(百分比)
                        String ndRange = TextUtils.isEmpty(bean.getNdRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getNdRange()) + "%";//负允许免偏差范围(百分比)
                        String range = "";
                        if (("--".equals(plRange) && "--".equals(ndRange))) {
                            range = "--";
                        } else {
                            range = ("--".equals(ndRange) ? "" : "-" + ndRange) + "  ~  " + ("--".equals(plRange) ? "" : plRange);

                        }
                        mTvFloatingRightYxpcfw.setText(range);

                        String range1 = mTvFloatingLeftYxpcfw.getText().toString().trim();
                        if (range1.equals(range)) {
                            mTvFloatingRightYxpcfw.setTextColor(Color.parseColor("#333333"));
                        } else {
                            mTvFloatingRightYxpcfw.setTextColor(Color.parseColor("#FFA500"));
                        }

                        ResultBargainBean bean_new = response.getData().getResult().get(0);
                        //约定电量 / 计量电量电价名称
                        String eItemId = bean.geteItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingRightYddlYdjg, "1", eItemId, peType, bean.geteItemName(), bean.geteItemValue(),
                                bean_new.geteItemName(), bean_new.geteItemValue(), response.getData().getBargain(), response.getData().getResult());

                        //正偏差电量电价名称
                        String plItemId = bean.getPlItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingRightZpcdldjYdjg, "2", plItemId, peType, bean.getPlItemName(), bean.getPlItemValue(),
                                bean_new.getPlItemName(), bean_new.getPlItemValue(), response.getData().getBargain(), response.getData().getResult());

                        //负偏差电量电价名称
                        String ndItemId = bean.getNdItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingRightFpcdldjUp, "3", ndItemId, peType, bean.getNdItemName(), bean.getNdItemValue(),
                                bean_new.getNdItemName(), bean_new.getNdItemValue(), response.getData().getBargain(), response.getData().getResult());

                    }
                }
            }

            if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
                mPresenter.getPackageInfoResAndBarg(OrderDetailsUtils.getPackageId(mCurrentMonth, mPackageInfoList), mIndentOrContractBean.getRelationId());
            } else {
                String floSchemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, false, mPackageInfoList);
                if (isMain) {
                    mPresenter.packageComparisonSchemeDetailTwo(floSchemeId, mIndentOrContractBean.getRelationId(), false);
                } else {
                    mPresenter.getPackageInfoResAndBarg(OrderDetailsUtils.getPackageId(mCurrentMonth, mPackageInfoList), mIndentOrContractBean.getRelationId());
                }
            }

            new CountDownTimer(2000, 1000) {
                @Override
                public void onTick(long l) {

                }

                @Override
                public void onFinish() {
                    setViewHeight();
                }
            };


        }
    }

    @Override
    public void getPriceDetail(PriceDetailBean response, boolean isMain) {
        if (response.getData() != null) {
            if (!response.getData().isEmpty()) {
                if (isMain) {
                    //基准/单一
                    for (PriceDetailBean.DataBean bean : response.getData()) {
                        // energyType  数据位置（01约定电量，02正偏差电量电价，03负偏差电量电价）
                        if ("01".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                mTvLeftYddlYdjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                mTvLeftYddlYdjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvLeftYddlGz.setText(result);
                                mTvLeftYddlGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("02".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_left_zpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_left_zpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvLeftZpcdldjGz.setText(result);
                                mTvLeftZpcdldjGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("03".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_left_fpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_left_fpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvLeftFpcdldjDown.setText(result);
                                mTvLeftFpcdldjDown.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                    }
                } else {
                    //浮动
                    for (PriceDetailBean.DataBean bean : response.getData()) {
                        // energyType  数据位置（01约定电量，02正偏差电量电价，03负偏差电量电价）
                        if ("01".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                mTvFloatingLeftYddlYdjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                mTvFloatingLeftYddlYdjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingLeftYddlGz.setText(result);
                                mTvFloatingLeftYddlGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("02".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_floating_left_zpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_floating_left_zpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingLeftZpcdldjGz.setText(result);
                                mTvFloatingLeftZpcdldjGz.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                        if ("03".equals(bean.getEnergyType())) {
                            if ("约定价差".equals(bean.getConfigName())) {
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" : BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue());
                                tv_floating_left_fpcdldj_ydjc.setText("约定价差:" + value + ("E111".equals(bean.getConfigId()) ? "元/度" : "%"));
                                tv_floating_left_fpcdldj_ydjc.setVisibility(TextUtils.isEmpty(value) ? View.GONE : View.VISIBLE);
                            } else {
                                String result = "";
                                String value = TextUtils.isEmpty(bean.getConfigValue()) ? "" :
                                        "E111".equals(bean.getConfigId()) ? BigDecimalUtils.onKeep5Decimal_divide(bean.getConfigValue()) + "元/度" :
                                                "x" + BigDecimalUtils.onKeep2Decimal_new(bean.getConfigValue()) + "%";
                                result += bean.getConfigName() + value;
                                mTvFloatingLeftFpcdldjDown.setText(result);
                                mTvFloatingLeftFpcdldjDown.setVisibility(TextUtils.isEmpty(result) ? View.GONE : View.VISIBLE);
                            }
                        }
                    }
                }
            }

            if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                mPresenter.getSchemeRes(schemeId, mIndentOrContractBean.getRelationId(), true);
            } else {
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                String floSchemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, false, mPackageInfoList);
                if (isMain) {
                    mPresenter.getPriceDetail(floSchemeId, mIndentOrContractBean.getRelationId(), false);
                } else {
                    mPresenter.getSchemeRes(schemeId, mIndentOrContractBean.getRelationId(), true);
                }
            }
        }
    }

    @Override
    public void getSchemeRes(SchemeResBean response, boolean isMain) {
        if (response.getData() != null && response.getData().size() > 0) {
            if (!response.getData().isEmpty()) {
                //调整前
                if (isMain) {
                    //基准/单一
                    if (response.getData().size() > 0) {
                        ResultBargainBean bean = response.getData().get(0);
                        // 分时段 分电量
                        String peType = bean.getPeType();//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                        switch (peType) {
                            case "01":
                                mTvLeftIsPeriodTime.setText("√");
                                mTvLeftIsConventionPower.setText("√");
                                tvSingleTitleName.setText("约定电量电价参数");
                                break;
                            case "02":
                                mTvLeftIsPeriodTime.setText("√");
                                mTvLeftIsConventionPower.setText("x");
                                tvSingleTitleName.setText("用电量电价参数");
                                break;
                            case "03":
                                mTvLeftIsPeriodTime.setText("x");
                                mTvLeftIsConventionPower.setText("√");
                                tvSingleTitleName.setText("约定电量电价参数");
                                break;
                            case "04":
                                mTvLeftIsPeriodTime.setText("x");
                                mTvLeftIsConventionPower.setText("x");
                                tvSingleTitleName.setText("用电量电价参数");
                                break;
                        }

                        //允许免偏差范围
                        String plRange = TextUtils.isEmpty(bean.getPlRange()) ? "--" :
                                BigDecimalUtils.onKeep2Decimal_new(bean.getPlRange()) + "%";//正允许免偏差范围(百分比)
                        String ndRange = TextUtils.isEmpty(bean.getNdRange()) ? "--" :
                                BigDecimalUtils.onKeep2Decimal_new(bean.getNdRange()) + "%";//负允许免偏差范围(百分比)
                        String range = "";
                        if (("--".equals(plRange) && "--".equals(ndRange))) {
                            range = "--";
                        } else {
                            range = ("--".equals(ndRange) ? "" : "-" + ndRange) + "  ~  " + ("--".equals(plRange) ? "" : plRange);
                        }
                        mTvLeftYxpcfw.setText(range);

                        //约定电量 / 计量电量电价名称
                        String eItemId = bean.geteItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvLeftYddlYdjg, "1", eItemId, peType, bean.geteItemName(), bean.geteItemValue(),
                                null, null, response.getData(), null);

                        //正偏差电量电价名称
                        String plItemId = bean.getPlItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvLeftZpcdldjYdjg, "2", plItemId, peType, bean.getPlItemName(), bean.getPlItemValue(),
                                null, null, response.getData(), null);

                        //负偏差电量电价名称
                        String ndItemId = bean.getNdItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvLeftFpcdldjUp, "3", ndItemId, peType, bean.getNdItemName(), bean.getNdItemValue(),
                                null, null, response.getData(), null);

                    }
                } else {
                    //浮动
                    if (response.getData().size() > 0) {
                        ResultBargainBean bean = response.getData().get(0);
                        // 分时段 分电量
                        String peType = bean.getPeType();//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                        switch (peType) {
                            case "01":
                                mTvFloatingLeftIsPeriodTime.setText("√");
                                mTvFloatingLeftIsConventionPower.setText("√");
                                tvFloTitleName.setText("约定电量电价参数");
                                break;
                            case "02":
                                mTvFloatingLeftIsPeriodTime.setText("√");
                                mTvFloatingLeftIsConventionPower.setText("x");
                                tvFloTitleName.setText("用电量电价参数");
                                break;
                            case "03":
                                mTvFloatingLeftIsPeriodTime.setText("x");
                                mTvFloatingLeftIsConventionPower.setText("√");
                                tvFloTitleName.setText("约定电量电价参数");
                                break;
                            case "04":
                                mTvFloatingLeftIsPeriodTime.setText("x");
                                mTvFloatingLeftIsConventionPower.setText("x");
                                tvFloTitleName.setText("用电量电价参数");
                                break;
                        }
                        //允许免偏差范围
                        String plRange = TextUtils.isEmpty(bean.getPlRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getPlRange()) + "%";//正允许免偏差范围(百分比)
                        String ndRange = TextUtils.isEmpty(bean.getNdRange()) ? "--" : BigDecimalUtils.onKeep2Decimal_new(bean.getNdRange()) + "%";//负允许免偏差范围(百分比)
                        String range = "";
                        if (("--".equals(plRange) && "--".equals(ndRange))) {
                            range = "--";
                        } else {
                            range = ("--".equals(ndRange) ? "" : "-" + ndRange) + "  ~  " + ("--".equals(plRange) ? "" : plRange);
                        }
                        mTvFloatingLeftYxpcfw.setText(range);

                        //约定电量 / 计量电量电价名称
                        String eItemId = bean.geteItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingLeftYddlYdjg, "1", eItemId, peType, bean.geteItemName(), bean.geteItemValue(),
                                null, null, response.getData(), null);

                        //正偏差电量电价名称
                        String plItemId = bean.getPlItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingLeftZpcdldjYdjg, "2", plItemId, peType, bean.getPlItemName(), bean.getPlItemValue(),
                                null, null, response.getData(), null);

                        //负偏差电量电价名称
                        String ndItemId = bean.getNdItemId();//约定电量 / 计量电量电价ID，根据D111判断是否为约定价格
                        OrderDetailsUtils.setViewData(mTvFloatingLeftFpcdldjUp, "3", ndItemId, peType, bean.getNdItemName(), bean.getNdItemValue(),
                                null, null, response.getData(), null);

                    }
                }
            }

            if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
                mPresenter.getPackageInfoRes(OrderDetailsUtils.getPackageId(mCurrentMonth, mPackageInfoList), mIndentOrContractBean.getRelationId());
            } else {
                String floSchemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, false, mPackageInfoList);
                if (isMain) {
                    mPresenter.getSchemeRes(floSchemeId, mIndentOrContractBean.getRelationId(), false);
                } else {
                    mPresenter.getPackageInfoRes(OrderDetailsUtils.getPackageId(mCurrentMonth, mPackageInfoList), mIndentOrContractBean.getRelationId());
                }
            }
        } else {
            if (null != mPackageInfoList && mPackageInfoList.size() > 0) {
                PackageInfoBean.DataDTO bean = mPackageInfoList.get(mMonthAdapter.getSelectPosition());
                // 分时段 分电量
                String peType = bean.getMainType();//分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
                switch (peType) {
                    case "01":
                        mTvLeftIsPeriodTime.setText("√");
                        mTvLeftIsConventionPower.setText("√");
                        break;
                    case "02":
                        mTvLeftIsPeriodTime.setText("√");
                        mTvLeftIsConventionPower.setText("x");
                        break;
                    case "03":
                        mTvLeftIsPeriodTime.setText("x");
                        mTvLeftIsConventionPower.setText("√");
                        break;
                    case "04":
                        mTvLeftIsPeriodTime.setText("x");
                        mTvLeftIsConventionPower.setText("x");
                        break;
                }
                mTvLeftYxpcfw.setText("--");
                mTvLeftYddlYdjg.setText("--");
                mTvLeftZpcdldjYdjg.setText("--");
                mTvLeftFpcdldjUp.setText("--");
                mTvLeftYddlYdjg.setTextColor(Color.parseColor("#FFA500"));
                mTvLeftZpcdldjYdjg.setTextColor(Color.parseColor("#FFA500"));
                mTvLeftFpcdldjUp.setTextColor(Color.parseColor("#FFA500"));
                mPresenter.getPackageInfoRes(OrderDetailsUtils.getPackageId(mCurrentMonth, mPackageInfoList), mIndentOrContractBean.getRelationId());

            }
        }

        new CountDownTimer(2000, 1000) {
            @Override
            public void onTick(long l) {

            }

            @Override
            public void onFinish() {
                setViewHeight();
            }
        };


    }

    @Override
    public void getPackageInfoResAndBarg(PackageInfoResAndBargBean response) {
        if (null != response && null != response.getData() && null != response.getData().getResult()) {
            //调整前
            String schemeRatio1 = response.getData().getResult().getSchemeRatio1();
            String value1 = TextUtils.isEmpty(schemeRatio1) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio1) + "%";
            mTvLeftUserUpNumber.setText(value1);

            String schemeRatio2 = response.getData().getResult().getSchemeRatio2();
            String value2 = TextUtils.isEmpty(schemeRatio2) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio2) + "%";
            mTvLeftUserDownNumber.setText(value2);

            //调整后
            String b_schemeRatio1 = response.getData().getBargain().getSchemeRatio1();
            String b_value1 = TextUtils.isEmpty(b_schemeRatio1) ? "--" : BigDecimalUtils.onKeep2Decimal_new(b_schemeRatio1) + "%";
            mTvRightUserUpNumber.setText(b_value1);

            if (value1.equals(b_value1)) {
                mTvRightUserUpNumber.setTextColor(Color.parseColor("#333333"));
            } else {
                mTvRightUserUpNumber.setTextColor(Color.parseColor("#FFA500"));
            }


            String b_schemeRatio2 = response.getData().getBargain().getSchemeRatio2();
            String b_value2 = TextUtils.isEmpty(b_schemeRatio2) ? "--" : BigDecimalUtils.onKeep2Decimal_new(b_schemeRatio2) + "%";
            mTvRightUserDownNumber.setText(b_value2);

            if (value2.equals(b_value2)) {
                mTvRightUserDownNumber.setTextColor(Color.parseColor("#333333"));
            } else {
                mTvRightUserDownNumber.setTextColor(Color.parseColor("#FFA500"));
            }


            dismissLoading();
            mRefreshLayout.finishRefresh();
        } else {//处理为空是从详情接口获取数据显示
            if (null != mPackageInfoList && mPackageInfoList.size() > 0) {
                PackageInfoBean.DataDTO dataDTO = mPackageInfoList.get(mMonthAdapter.getSelectPosition());
                //调整前
                String schemeRatio1 = dataDTO.getSchemeRatio1();
                String value1 = TextUtils.isEmpty(schemeRatio1) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio1) + "%";
                mTvLeftUserUpNumber.setText(value1);

                String schemeRatio2 = dataDTO.getSchemeRatio2();
                String value2 = TextUtils.isEmpty(schemeRatio2) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio2) + "%";
                mTvLeftUserDownNumber.setText(value2);
            }
            dismissLoading();
            mRefreshLayout.finishRefresh();
        }
    }

    @Override
    public void getPackageInfoRes(PackageInfoResBean response) {
        if (response.getData() != null) {
            //调整前
            String schemeRatio1 = response.getData().getSchemeRatio1();
            String value1 = TextUtils.isEmpty(schemeRatio1) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio1) + "%";
            mTvLeftUserUpNumber.setText(value1);

            String schemeRatio2 = response.getData().getSchemeRatio2();
            String value2 = TextUtils.isEmpty(schemeRatio2) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio2) + "%";
            mTvLeftUserDownNumber.setText(value2);
            dismissLoading();
            mRefreshLayout.finishRefresh();
        } else {//处理为空是从详情接口获取数据显示
            if (null != mPackageInfoList && mPackageInfoList.size() > 0) {
                PackageInfoBean.DataDTO dataDTO = mPackageInfoList.get(mMonthAdapter.getSelectPosition());
                //调整前
                String schemeRatio1 = dataDTO.getSchemeRatio1();
                String value1 = TextUtils.isEmpty(schemeRatio1) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio1) + "%";
                mTvLeftUserUpNumber.setText(value1);

                String schemeRatio2 = dataDTO.getSchemeRatio2();
                String value2 = TextUtils.isEmpty(schemeRatio2) ? "--" : BigDecimalUtils.onKeep2Decimal_new(schemeRatio2) + "%";
                mTvLeftUserDownNumber.setText(value2);
            }
            dismissLoading();
            mRefreshLayout.finishRefresh();
        }
    }

    @Override
    public void priceChange(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void cancelBargainSuccess(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void userRejectBargainSuccess(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void relieveContractSuccess(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void rejectPriceChange(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void confirmPriceChange(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void cancelPriceChange(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void cancelPowerChange(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void cancelRelieveContract(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void revokeSupplementContractSuccess(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void cancelOrderSuccess(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void applyForBargainSuccess(BaseResponse response) {
        onRefreshPage(response.getMsg());
    }

    @Override
    public void getContractList(IndentBean response) {
        if (response != null) {
            if (response.getCode() == 200) {
                if (response.getData() != null) {
                    if (!response.getData().getList().isEmpty()) {
                        mIndentOrContractBean = response.getData().getList().get(0);
                        if (mIndentOrContractBean != null) {
                            String result = OrderDetailsUtils.status_left(mIndentOrContractBean.getModificationType()) + OrderDetailsUtils.status_right(mIndentOrContractBean.getmStatus());
                            mTitleBar.setTitle(result);

                            mTvCompanyName.setText(mIndentOrContractBean.getMembersSdName());
                            String img_url = HttpInterConst.BASEURL_IMG + mIndentOrContractBean.getFileIdComb();
                            Glide.with(mContext).load(img_url).placeholder(R.mipmap.order_goods_deft).error(R.mipmap.order_goods_deft).into(mIvPackageLogo);
//                            mTvPackageName.setText(mIndentOrContractBean.getSellingPoint());
                            mTvPackageName.setText(TextUtil.getName(mIndentOrContractBean.getSellingPoint(), mIndentOrContractBean.getCreditRating()));
                            String start_time = TextUtils.isEmpty(mIndentOrContractBean.getStartDate()) ? "" : DateUtils.getStrng_to_Times_ymd_2(mIndentOrContractBean.getStartDate());
                            String end_time = TextUtils.isEmpty(mIndentOrContractBean.getEndDate()) ? "" : DateUtils.getStrng_to_Times_ymd_2(mIndentOrContractBean.getEndDate());
                            tv_order_hyzq.setText(start_time + "~" + end_time);
                            mTvPackageTime.setText(mIndentOrContractBean.getCombCode());
                            mTvOrderNumber.setText(mIndentOrContractBean.getRelCode());
                            mTvOrderTime.setText(DateUtils.getStrng_to_Times_ymd_5(mIndentOrContractBean.getApplicationDate()));
                            mTvPackageStatus.setText(EnumUtils.getGreenLeft(mIndentOrContractBean.getConstrRel()) + "  " +
                                    EnumUtils.getGreenCenter(mIndentOrContractBean.getConstrMod()) + "  " +
                                    EnumUtils.getGreenRight(mIndentOrContractBean.getConstrBarg()));

                            mPresenter.getPackageInfo(mIndentOrContractBean.getCombId(), mIndentOrContractBean.getRelationId(), mIndentOrContractBean.getStartDate(), mIndentOrContractBean.getEndDate());
                        }
                    }
                }
            }
        }
    }

    @Override
    public void orderCheckSuccess(String relationId) {
        ARouter.getInstance()
                .build(OrderArouterPath.ORDER_CONFIRMORDER)
                .withString("mRelationId", relationId)
                .withInt("pageFlag", 2)
                .navigation(OrderDetailsActivity.this, 1000);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1000 && resultCode == 10001) {
            from = "2";
            onRefreshPage("");
        }
        if (resultCode == RESULT_OK) {
            if (requestCode == 1100) {
                onRefreshPage("");
            }
        }
    }

    /**
     * 公共的显示和隐藏 是1列还是2列
     *
     * @param relStatus
     * @param modificationType
     * @param mStatus
     */
    public void on1Or2column(String relStatus, String modificationType, String mStatus) {
        //类型为合约时，变更状态为电价变更205，订单状态已生效3，审核状态售电公司已确认104
        //类型为订单时，变更状态为议价203，订单状态待确认1，审核状态售电公司已确认104
        if ("1".equals(from)) {//1为订单 2为合约
            if ("1".equals(relStatus) && "104".equals(mStatus) && "203".equals(modificationType)) {
                //两列
                isPlayChenged(true);
            } else {
                //一列
                isPlayChenged(false);
            }
            changePlayBottomBtn(relStatus, modificationType, mStatus, false, false);
        } else {
            if ("3".equals(relStatus) && "104".equals(mStatus) && "205".equals(modificationType)) {
                //两列
                isPlayChenged(true);
            } else {
                //一列
                isPlayChenged(false);
            }
        }

        if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
            ll_floating.setVisibility(View.GONE);
        } else {
            ll_floating.setVisibility(View.VISIBLE);
        }
    }

    public void isPlayChenged(boolean isPlay) {
        if (isPlay) {
            mLlBasePackageTitle.setVisibility(View.VISIBLE);
            mRlRightUserUpNumber.setVisibility(View.VISIBLE);
            mRlRightUserDownNumber.setVisibility(View.VISIBLE);
            mRlRightIsPeriodTime.setVisibility(View.VISIBLE);
            mRlRightIsConventionPower.setVisibility(View.VISIBLE);
            mRlRightYxpcfw.setVisibility(View.VISIBLE);
            mRlRightYddl.setVisibility(View.VISIBLE);
            mRlRightZpcdldj.setVisibility(View.VISIBLE);
            mRlRightFpcdldj.setVisibility(View.VISIBLE);

            mRlFloatingRightIsPeriodTime.setVisibility(View.VISIBLE);
            mRlFloatingRightIsConventionPower.setVisibility(View.VISIBLE);
            mRlFloatingRightYxpcfw.setVisibility(View.VISIBLE);
            mRlFloatingRightYddl.setVisibility(View.VISIBLE);
            mRlFloatingRightZpcdldj.setVisibility(View.VISIBLE);
            mRlFloatingRightFpcdldj.setVisibility(View.VISIBLE);

            if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                mPresenter.packageComparisonPriceDetailTwo(schemeId, mIndentOrContractBean.getRelationId(), true);
            } else {
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                mPresenter.packageComparisonPriceDetailTwo(schemeId, mIndentOrContractBean.getRelationId(), true);
            }
        } else {
            mLlBasePackageTitle.setVisibility(View.GONE);
            mRlRightUserUpNumber.setVisibility(View.GONE);
            mRlRightUserDownNumber.setVisibility(View.GONE);
            mRlRightIsPeriodTime.setVisibility(View.GONE);
            mRlRightIsConventionPower.setVisibility(View.GONE);
            mRlRightYxpcfw.setVisibility(View.GONE);
            mRlRightYddl.setVisibility(View.GONE);
            mRlRightZpcdldj.setVisibility(View.GONE);
            mRlRightFpcdldj.setVisibility(View.GONE);

            mRlFloatingRightIsPeriodTime.setVisibility(View.GONE);
            mRlFloatingRightIsConventionPower.setVisibility(View.GONE);
            mRlFloatingRightYxpcfw.setVisibility(View.GONE);
            mRlFloatingRightYddl.setVisibility(View.GONE);
            mRlFloatingRightZpcdldj.setVisibility(View.GONE);
            mRlFloatingRightFpcdldj.setVisibility(View.GONE);

            if ("1".equals(mIndentOrContractBean.getpNum())) {//单一套餐：1/组合套餐：2
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                mPresenter.getPriceDetail(schemeId, mIndentOrContractBean.getRelationId(), true);
            } else {
                String schemeId = OrderDetailsUtils.getIdbyPackageInfo(mCurrentMonth, true, mPackageInfoList);
                mPresenter.getPriceDetail(schemeId, mIndentOrContractBean.getRelationId(), true);
            }
        }
    }

    /**
     * 控制底部按钮显示逻辑
     *
     * @param relStatus        订单状态：待确认1，已生效3，已关闭4，已解约5，已完结6，待评价9
     * @param modificationType 变更类型：合约建立201，电量变更202，议价203，合约解除204，电价变更205
     * @param mStatus          审核状态：待用户确认101，待售电公司确认102，用户已确认103，售电公司已确认104，用户已驳回105，售电公司已驳回106，用户已撤回107，售电公司已撤回108
     * @param powerChange      电量变更功能是否具备
     * @param priceChange      电价变更功能是否具备
     */
    public void changePlayBottomBtn(String relStatus, String modificationType, String mStatus, boolean powerChange, boolean priceChange) {
        ll_bottom.setVisibility(View.GONE);
        mRlBgdj.setVisibility(View.GONE);
        mRlCxyj.setVisibility(View.GONE);
        mRlBhyj.setVisibility(View.GONE);
        mRlBgdl.setVisibility(View.GONE);
        mDjbgcx.setVisibility(View.GONE);
        mDlbgcx.setVisibility(View.GONE);
        mDjbgqr.setVisibility(View.GONE);
        mRlDjbgbh.setVisibility(View.GONE);
        mRlJchy.setVisibility(View.GONE);
        mRlLjqr.setVisibility(View.GONE);
        mRlHyjccx.setVisibility(View.GONE);
        mRlZcgm.setVisibility(View.GONE);
        mRlHtxq.setVisibility(View.GONE);
        mRlLjpj.setVisibility(View.GONE);

        rl_cxbabcxy.setVisibility(View.GONE);
        rl_bcxyqr.setVisibility(View.GONE);
        rl_babcxy.setVisibility(View.GONE);
        isAddBottomBtn = false;
        rl_qxdd.setVisibility(View.GONE);
        rl_sqyj.setVisibility(View.GONE);

        contract_month_status_linner.setVisibility(View.GONE);
        PackageOrdersBean.DataBean bean = OrderDetailsUtils.getPackageOrdersBean(mCurrentMonth, mPackageOrdersBeanList);
        btnArraylist.clear();
        btoomBtnArraylist.clear();
        switch (relStatus) {
            case "1":
                if ("203".equals(modificationType) && "102".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    //撤销议价
                    mRlCxyj.setVisibility(View.VISIBLE);
                    rl_qxdd.setVisibility(View.VISIBLE);
                }
                if ("203".equals(modificationType) && "104".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    //驳回议价
                    mRlBhyj.setVisibility(View.VISIBLE);
                    //立即确认
                    mRlLjqr.setVisibility(View.VISIBLE);
                }
                if ("203".equals(modificationType) && "105".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    rl_qxdd.setVisibility(View.VISIBLE);
                    rl_sqyj.setVisibility(View.VISIBLE);
                }
                if ("203".equals(modificationType) && "106".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    rl_qxdd.setVisibility(View.VISIBLE);
                    rl_sqyj.setVisibility(View.VISIBLE);
                }
                if ("203".equals(modificationType) && "107".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    rl_qxdd.setVisibility(View.VISIBLE);
                    rl_sqyj.setVisibility(View.VISIBLE);
                }
                break;
            case "3":
               /*
               *  当合约下拉接口powerChange为true,priceChange为true时，
                用户已确认103，（合约建立201或者 电价变更205） 或者
                用户已撤回107，（电量变更202或者 电价变更205） 或者
                用户已驳回105，电价变更205 或者
                售电公司已驳回106 ,（电量变更202或者 电价变更205）
                存在“电量变更”，“电价变更”，“合约解除”功能*/
                int visibalNum = 0;

                //这段判断主要是为了防止合约最后一个月刚好等于当前时间月份时，合约接触按钮错误显示的问题。
                //当合约处于生效状态时，合约的最后一个月刚好等于当前时间月份时，合约解除按钮应当隐藏，否则显示
                boolean shouldShowJCHY=true;
                if (month_list != null && month_list.size() != 0) {
                  String lastMonth= targetYear+"-"+month_list.get(month_list.size()-1).replace("月","");
                    String nowTime=  TimeUtils.date2String(TimeUtils.getNowDate(),"yyyy-MM");
                    if(lastMonth.compareTo(nowTime)==0){
                        shouldShowJCHY=false;
                    }
                }


                //这段判断主要是为了防止已经过去的月份扔错误显示变更电价等错误操作
                //当用户选择的月份小于当前时间月的时候则判定不显示变更电价、电量、变更确认等按钮。
                boolean shouldShowBG=true;
                if (!TextUtils.isEmpty(userSelectTime)) {
                    if (userSelectTime.compareTo(TimeUtils.getNowString()) < 0) {
//                        mRlBgdj.setVisibility(View.GONE);
//                        mRlBgdl.setVisibility(View.GONE);
//                        mDjbgqr.setVisibility(View.GONE);
                        shouldShowBG=false;
                    }
                } else {
                    if (month_list != null && month_list.size() != 0) {
//                        int month=Calendar.getInstance().get(Calendar.MONTH);
                        String selectMonth=mCurrentMonth;
                        userSelectTime = targetYear + "-" + selectMonth.replace("月", "");

                        if (userSelectTime.compareTo(TimeUtils.getNowString()) < 0) {
//                            mRlBgdj.setVisibility(View.GONE);
//                            mRlBgdl.setVisibility(View.GONE);
//                            mDjbgqr.setVisibility(View.GONE);
                            shouldShowBG=false;
                        }
                    }
                }


                if (powerChange && priceChange) {
                    if (
                            ("103".equals(mStatus) && ("201".equals(modificationType) || "205".equals(modificationType))) ||
                                    ("107".equals(mStatus) && ("202".equals(modificationType) || "205".equals(modificationType) || "204".equals(modificationType))) ||
                                    ("106".equals(mStatus) && ("202".equals(modificationType) || "205".equals(modificationType))) ||
                                    ("105".equals(mStatus) && "205".equals(modificationType)) ||
                                    ("104".equals(mStatus) && "202".equals(modificationType)) ||
                                    ("103".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("104".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("105".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("106".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("106".equals(mStatus) && "204".equals(modificationType)) ||
                                    ("107".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("108".equals(mStatus) && "206".equals(modificationType))
                    ) {
                        ll_bottom.setVisibility(View.VISIBLE);

                        if(shouldShowJCHY){
                            if (visibalNum < 3) {
                                //合约解除
                                mRlJchy.setVisibility(View.VISIBLE);
                                btoomBtnArraylist.add(btnlist[12]);
                                visibalNum++;
                            } else {
                                btnArraylist.add(btnlist[12]);
                            }
                        }


                        if ("1".equals(mIndentOrContractBean.getConstrMod())) {//1可变更
                            if(shouldShowBG){
                                if (visibalNum < 3) {
                                    //电量变更
                                    mRlBgdl.setVisibility(View.VISIBLE);
                                    btoomBtnArraylist.add(btnlist[7]);
                                    visibalNum++;
                                } else {
                                    btnArraylist.add(btnlist[7]);
                                }
                            }

                            if(shouldShowBG){
                                if (visibalNum < 3) {
                                    //电价变更
                                    mRlBgdj.setVisibility(View.VISIBLE);
                                    btoomBtnArraylist.add(btnlist[4]);
                                    visibalNum++;
                                } else {
                                    btnArraylist.add(btnlist[4]);
                                }
                            }

//                            String[] btnlist = {"撤销备案补充协议", "补充协议确认", "补充协议", "合同详情", "变更电价", "撤销议价", "驳回议价", "变更电量", "电价变更撤销", "电量变更撤销", "电价变更确认", "电价变更驳回", "解除合约", "合约解除撤销", "立即确认", "再次购买", "立即评价"};

                        }

                        isAddBottomBtn = true;
                    }
                }

                /*
                * 当powerChange为false,priceChange为true时，
                    用户已确认103，（合约建立201或者 电价变更205） 或者
                    用户已撤回107， 电价变更205 或者
                    用户已驳回105，电价变更205 或者
                    售电公司已驳回106 ,电价变更205
                    * 存在“电价变更”，“合约解除”功能*/
                if (!powerChange && priceChange) {
                    if (
                            ("103".equals(mStatus) && ("201".equals(modificationType) || "205".equals(modificationType))) ||
                                    ("107".equals(mStatus) && ("205".equals(modificationType) || "204".equals(modificationType))) ||
                                    ("105".equals(mStatus) && "205".equals(modificationType)) ||
                                    ("106".equals(mStatus) && "205".equals(modificationType)) ||
                                    ("103".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("104".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("105".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("106".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("106".equals(mStatus) && "204".equals(modificationType)) ||
                                    ("107".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("108".equals(mStatus) && "206".equals(modificationType))

                    ) {
                        ll_bottom.setVisibility(View.VISIBLE);
                        if ("1".equals(mIndentOrContractBean.getConstrMod())) {//1可变更
                            if(shouldShowBG){
                                if (visibalNum < 3) {
                                    //电价变更
                                    mRlBgdj.setVisibility(View.VISIBLE);
                                    btoomBtnArraylist.add(btnlist[4]);
                                    visibalNum++;
                                } else {
                                    btnArraylist.add(btnlist[4]);
                                }
                            }
                        }
                        if(shouldShowJCHY){
                            if (visibalNum < 3) {
                                //合约解除
                                mRlJchy.setVisibility(View.VISIBLE);
                                btoomBtnArraylist.add(btnlist[12]);
                                visibalNum++;
                            } else {
                                btnArraylist.add(btnlist[12]);
                            }
                        }
                        isAddBottomBtn = true;
                    }
                }

                if (!powerChange && !priceChange) {
                    if (
                            ("103".equals(mStatus) && ("201".equals(modificationType) || "205".equals(modificationType))) ||
                                    ("107".equals(mStatus) && ("202".equals(modificationType) || "205".equals(modificationType) || "204".equals(modificationType))) ||
                                    ("106".equals(mStatus) && ("202".equals(modificationType) || "205".equals(modificationType))) ||
                                    ("105".equals(mStatus) && "205".equals(modificationType)) ||
                                    ("104".equals(mStatus) && "202".equals(modificationType)) ||
                                    ("103".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("104".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("105".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("106".equals(mStatus) && "206".equals(modificationType)) ||
                                    ("106".equals(mStatus) && "204".equals(modificationType)) ||
                                    ("107".equals(mStatus) && "206".equals(modificationType))

                    ) {
                        ll_bottom.setVisibility(View.VISIBLE);
                        if(shouldShowJCHY){
                            if (visibalNum < 3) {
                                //合约解除
                                mRlJchy.setVisibility(View.VISIBLE);
                                btoomBtnArraylist.add(btnlist[12]);
                                visibalNum++;
                            } else {
                                btnArraylist.add(btnlist[12]);
                            }
                        }

                        isAddBottomBtn = true;
                    }

                }

                if ("102".equals(mStatus) && "205".equals(modificationType)) {
                    //电价变更撤销
                    if (bean == null) {
                        return;
                    }
                    if (!TextUtils.isEmpty(bean.getMContent())) {
                        if ("1".equals(mIndentOrContractBean.getConstrMod())) {//1可变更
                            ll_bottom.setVisibility(View.VISIBLE);
                            if (visibalNum < 3) {
                                //电价变更撤销
                                mDjbgcx.setVisibility(View.VISIBLE);
                                btoomBtnArraylist.add(btnlist[8]);
                                visibalNum++;
                            } else {
                                btnArraylist.add(btnlist[8]);
                            }
                        }
                    }
                }
                if ("102".equals(mStatus) && "202".equals(modificationType)) {
                    //电量变更撤销
                    if (bean == null) {
                        return;
                    }
                    if (!TextUtils.isEmpty(bean.getMContent())) {
                        if ("1".equals(mIndentOrContractBean.getConstrMod())) {//1可变更
                            ll_bottom.setVisibility(View.VISIBLE);
                            if (visibalNum < 3) {
                                //电量变更撤销
                                mDlbgcx.setVisibility(View.VISIBLE);
                                btoomBtnArraylist.add(btnlist[9]);
                                visibalNum++;
                            } else {
                                btnArraylist.add(btnlist[9]);
                            }
                        }
                    }
                }
                if ("104".equals(mStatus) && "205".equals(modificationType)) {
                    if (bean == null) {
                        return;
                    }
                    if (!TextUtils.isEmpty(bean.getMContent())) {
                        if ("1".equals(mIndentOrContractBean.getConstrMod())) {//1可变更
                            ll_bottom.setVisibility(View.VISIBLE);
                            if(shouldShowBG){
                                if (visibalNum < 3) {
                                    //电价变更确认
                                    mDjbgqr.setVisibility(View.VISIBLE);
                                    btoomBtnArraylist.add(btnlist[10]);
                                    visibalNum++;
                                } else {
                                    btnArraylist.add(btnlist[10]);
                                }
                            }

                            if (visibalNum < 3) {
                                //电价变更驳回
                                mRlDjbgbh.setVisibility(View.VISIBLE);
                                btoomBtnArraylist.add(btnlist[11]);
                                visibalNum++;
                            } else {
                                btnArraylist.add(btnlist[11]);
                            }
                        }
                    }
                }
                if ("102".equals(mStatus) && "204".equals(modificationType)) {
                    ll_bottom.setVisibility(View.VISIBLE);

                    if (visibalNum < 3) {
                        //合约解除撤销
                        mRlHyjccx.setVisibility(View.VISIBLE);
                        btoomBtnArraylist.add(btnlist[13]);
                        visibalNum++;
                    } else {
                        btnArraylist.add(btnlist[13]);
                    }
                }
                if ("206".equals(modificationType) && "101".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);

                    if (visibalNum < 3) {
                        //补充协议确认
                        rl_bcxyqr.setVisibility(View.VISIBLE);
                        btoomBtnArraylist.add(btnlist[1]);
                        visibalNum++;
                    } else {
                        btnArraylist.add(btnlist[1]);
                    }


                }
                if ("206".equals(modificationType) && "102".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    if (visibalNum < 3) {
                        //撤销备案补充协议
                        rl_cxbabcxy.setVisibility(View.VISIBLE);
                        btoomBtnArraylist.add(btnlist[0]);
                        visibalNum++;
                    } else {
                        btnArraylist.add(btnlist[0]);
                    }
                }
                ///合同详情显示逻辑
                if ("201".equals(modificationType) && "103".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    if (visibalNum < 3) {
                        //合同详情
                        mRlHtxq.setVisibility(View.VISIBLE);
                        btoomBtnArraylist.add(btnlist[3]);
                        visibalNum++;
                    } else {
                        btnArraylist.add(btnlist[3]);
                    }
                }

                if ("202".equals(modificationType) && ("104".equals(mStatus) || "106".equals(mStatus) || "107".equals(mStatus))) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    if (visibalNum < 3) {
                        //合同详情
                        mRlHtxq.setVisibility(View.VISIBLE);
                        btoomBtnArraylist.add(btnlist[3]);
                        visibalNum++;
                    } else {
                        btnArraylist.add(btnlist[3]);
                    }
                }

                if ("205".equals(modificationType) && ("103".equals(mStatus) || "105".equals(mStatus) || "107".equals(mStatus))) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    if (visibalNum < 3) {
                        //合同详情
                        mRlHtxq.setVisibility(View.VISIBLE);
                        btoomBtnArraylist.add(btnlist[3]);
                        visibalNum++;
                    } else {
                        btnArraylist.add(btnlist[3]);
                    }
                }

                if ("204".equals(modificationType) && "107".equals(mStatus)) {
                    ll_bottom.setVisibility(View.VISIBLE);
                    if (visibalNum < 3) {
                        //合同详情
                        mRlHtxq.setVisibility(View.VISIBLE);
                        btoomBtnArraylist.add(btnlist[3]);
                        visibalNum++;
                    } else {
                        btnArraylist.add(btnlist[3]);
                    }
                }


                //补充协议
                ll_bottom.setVisibility(View.VISIBLE);

                if (visibalNum < 3) {
                    //补充协议
                    rl_babcxy.setVisibility(View.VISIBLE);
                    btoomBtnArraylist.add(btnlist[2]);
                    visibalNum++;
                } else {
                    btnArraylist.add(btnlist[2]);
                }
                if (visibalNum < 3) {
                    //合同详情
                    mRlHtxq.setVisibility(View.VISIBLE);
                    btoomBtnArraylist.add(btnlist[3]);
                    visibalNum++;
                } else {
                    btnArraylist.add(btnlist[3]);
                }


//                if (!TextUtils.isEmpty(userSelectTime)) {
//                    if (userSelectTime.compareTo(TimeUtils.getNowString()) < 0) {
////                        mRlBgdj.setVisibility(View.GONE);
////                        mRlBgdl.setVisibility(View.GONE);
////                        mDjbgqr.setVisibility(View.GONE);
//                        shouldShowBG=false;
//                    }
//                } else {
//                    if (month_list != null && month_list.size() != 0) {
////                        int month=Calendar.getInstance().get(Calendar.MONTH);
//                        String selectMonth=mCurrentMonth;
//                        userSelectTime = targetYear + "-" + selectMonth.replace("月", "");
//
//                        if (userSelectTime.compareTo(TimeUtils.getNowString()) < 0) {
////                            mRlBgdj.setVisibility(View.GONE);
////                            mRlBgdl.setVisibility(View.GONE);
////                            mDjbgqr.setVisibility(View.GONE);
//                            shouldShowBG=false;
//                        }
//                    }
//                }


                //分月订单状态显示部分
                contract_month_status_linner.setVisibility(View.VISIBLE);
                contract_month_status.setText("已生效");
                break;
            case "4":
                break;
            case "5"://已解约
                ll_bottom.setVisibility(View.VISIBLE);
                //合同详情
                mRlHtxq.setVisibility(View.VISIBLE);
                //补充协议
                rl_babcxy.setVisibility(View.VISIBLE);

                //分月订单状态显示部分
                contract_month_status_linner.setVisibility(View.VISIBLE);

                String relieveDate5 = DateUtils.getStrng_to_Times_ymd_3(updateDate);

                if (!TextUtils.isEmpty(userSelectTime)) {
                    if (userSelectTime.compareTo(relieveDate5) > 0) {
                        //已解约
                        contract_month_status.setText("已解约");
                    } else if (userSelectTime.compareTo(relieveDate5) < 0) {
                        //已生效
                        contract_month_status.setText("已生效");
                    } else if (userSelectTime.compareTo(relieveDate5) == 0) {
                        if (userSelectTime.compareTo(TimeUtils.getNowString()) < 0) {
                        //已生效
                            contract_month_status.setText("已生效");
                        } else if (userSelectTime.compareTo(TimeUtils.getNowString()) ==0) {
                            contract_month_status.setText("已生效");
                        }else{
                            contract_month_status.setText("已解约");
                        }
                    }
                } else {
                    if (month_list != null && month_list.size() != 0) {
                        String selectMonth=mCurrentMonth;
                        userSelectTime = targetYear + "-" + selectMonth.replace("月", "");

                        if (userSelectTime.compareTo(relieveDate5) > 0) {
                            //已解约
                            contract_month_status.setText("已解约");
                        } else if (userSelectTime.compareTo(relieveDate5) < 0) {
                            //已生效
                            contract_month_status.setText("已生效");
                        } else if (userSelectTime.compareTo(relieveDate5) == 0) {
                            if (userSelectTime.compareTo(TimeUtils.getNowString()) < 0) {
                                //已生效
                                contract_month_status.setText("已生效");
                            } else if (userSelectTime.compareTo(TimeUtils.getNowString()) ==0) {
                                contract_month_status.setText("已生效");
                            }
                        }
                    }

                }

                break;
            case "6":
                ll_bottom.setVisibility(View.VISIBLE);
                //再次购买
//                mRlZcgm.setVisibility(View.VISIBLE);
                //合同详情
                mRlHtxq.setVisibility(View.VISIBLE);
                //补充协议
                rl_babcxy.setVisibility(View.VISIBLE);

                //分月订单状态显示部分
                contract_month_status_linner.setVisibility(View.VISIBLE);
                contract_month_status.setText("已完结");
                break;
            case "9":
                ll_bottom.setVisibility(View.VISIBLE);
                //立即评价
//                mRlLjpj.setVisibility(View.VISIBLE);
                //合同详情
                mRlHtxq.setVisibility(View.VISIBLE);
                //补充协议
                rl_babcxy.setVisibility(View.VISIBLE);
                //分月订单状态显示部分
                contract_month_status_linner.setVisibility(View.VISIBLE);
                contract_month_status.setText("待评价");
                break;
        }
        if (isClickMonth) {
            isClickMonth = false;
            dismissLoading();
        }


        getfinalBtnList(btnArraylist);
    }

    private void getfinalBtnList(List<String> btnlist) {
        List<String> list = delRepeat(btnlist);
        List<String> fnlist = new ArrayList<>();
        if (list.size() != 0) {
            for (int i = 0; i < list.size(); i++) {
                boolean isRepeat = false;
                for (int j = 0; j < btoomBtnArraylist.size(); j++) {
                    if (TextUtils.equals(list.get(i), btoomBtnArraylist.get(j))) {
                        isRepeat = true;
                        break;
                    }
                }
                if (!isRepeat) {
                    fnlist.add(list.get(i));
                }
            }
        }
        if (fnlist.size() == 0) {
            tv_more.setVisibility(View.GONE);
        } else {
            tv_more.setVisibility(View.VISIBLE);
            finalList = fnlist;
        }
    }

    public List<String> delRepeat(List<String> list) {
        List<String> myList = list.stream().distinct().collect(Collectors.toList());
        return myList;
    }


    private void showBtnPop(List<String> targetList) {
        String[] strings = finalList.toArray(new String[finalList.size()]);
        new XPopup.Builder(this)
                .hasShadowBg(false)
                .atView(tv_more)  // 依附于所点击的View，内部会自动判断在上方或者下方显示
                .asAttachList(strings,
                        null,
                        new OnSelectListener() {
                            @Override
                            public void onSelect(int position, String text) {
                                botoomBtnClick(text);
                            }
                        }, 0, 0, Gravity.CENTER).show();
    }

    private void botoomBtnClick(String btnName) {
        int btnPosition = -1;
        for (int i = 0; i < btnlist.length; i++) {
            if (TextUtils.equals(btnName, btnlist[i])) {
                btnPosition = i;
                break;
            }
        }
        switch (btnPosition) {
            case 0:
                //撤销备案补充协议
                cxbcxy();
                break;
            case 1:
                //补充协议确认
                bcxyqr();
                break;
            case 2:
                //补充协议
                bcxy();
                break;
            case 3:
                //合同详情
                htxq();
                break;
            case 4:
                //变更电价
                bgdj();
                break;
            case 5:
                //撤销议价
                cxyj();
                break;
            case 6:
                //驳回议价
                bhyj();
                break;
            case 7:
                //变更电量
                bgdl();
                break;
            case 8:
                //电价变更撤销
                djbgcx();
                break;
            case 9:
                //电量变更撤销
                dlbgcx();
                break;
            case 10:
                //电价变更确认
                djbgqr();
                break;
            case 11:
                //电价变更驳回
                djbgbh();
                break;
            case 12:
                //解除合约
                jchy();
                break;
            case 13:
                //合约解除撤销
                hyjccx();
                break;
            case 14:
                //立即确认

                break;
            case 15:
                //再次购买

                break;
            case 16:
                //立即评价

                break;

        }

    }

    //撤销备案补充协议
    private void cxbcxy() {
        DialogUtil.showConfirm(mContext, "提示", "是否确认撤销本条补充协议？",
                new OnConfirmListener() {
                    @Override
                    public void onConfirm() {
                        String relationId = mIndentOrContractBean.getRelationId();
                        mPresenter.revokeSupplementContract(relationId);
                    }
                });
    }

    private void bcxyqr() {
        ARouter.getInstance()
                .build(OrderArouterPath.ORDER_CONFIRMSUPPLEMENTARYAGREEMENT)
                .withString("relationId", mIndentOrContractBean.getRelationId())
                .navigation();
    }

    private void bcxy() {
        ARouter.getInstance()
                .build(OrderArouterPath.ORDER_SUPPLEMENTCONTRACT)
                .withString("relationId", mIndentOrContractBean.getRelationId())
                .withBoolean("isAddBottomBtn", isAddBottomBtn)
                .navigation();
    }

    private void htxq() {
        ARouter.getInstance()
                .build(OrderArouterPath.ORDER_CONTRACTDETAILS)
                .withString("hyxqFileId", mIndentOrContractBean.getHyxqFileId())
                .navigation();
    }

    private void bgdj() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage(String.format("是否确认提交%s电价变更申请吗？", mCurrentMonth.contains("月")
                ? mCurrentMonth : mCurrentMonth + "月"));
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
//                        DialogUtil.showInputCodeDialog(mContext, 4,
//                                new DialogUtil.OnInputCodeVerifyCodeListener() {
//                                    @Override
//                                    public void onVerifyCode() {
                PackageOrdersBean.DataBean bean = OrderDetailsUtils.getPackageOrdersBean(mCurrentMonth.contains("月")
                        ? mCurrentMonth.replace("月", "") : mCurrentMonth, mPackageOrdersBeanList);
                String relationId = mIndentOrContractBean.getRelationId();
                String packageId = bean.getPackageId();
                String monthDate = DateUtils.getStrng_to_Times_ymd_2(bean.getMonthDate());
                mPresenter.priceChange(relationId, packageId, monthDate);

//                                    }
//                                });


            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();

    }

    private void cxyj() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage("撤销议价后需要重新发起，是否确认撤销？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.cancelBargain(relationId);
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }


    private void bhyj() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage("驳回议价后需要重新发起，是否确认驳回？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.userRejectBargain(relationId);
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }

    private void bgdl() {
        PackageInfoBean.DataDTO dataDTO = OrderDetailsUtils.getBeanByPackageInfo(mCurrentMonth, mPackageInfoList);
        boolean result = false;
        if ("1".equals(dataDTO.getPNum())) {//单一套餐：1/组合套餐：2
            //"mainType": //基准套餐：分时分电量01，分时不分电量02，不分时分电量03，不分时不分电量04
            if ("01".equals(dataDTO.getMainType()) || "02".equals(dataDTO.getMainType())) {
                result = true;
            }
        } else {

            String peType = OrderDetailsUtils.getGoodsType(dataDTO.getMainType(), dataDTO.getFloType());
            if ("01".equals(peType) || "02".equals(peType)) {
                result = true;
            }
        }
        String aRouter_url = "";
        if (result) {
            //电量变更--分时段
            aRouter_url = OrderArouterPath.ORDER_DAYPARTINGELECHANGES;
        } else {
            //电量变更--不分时段
            aRouter_url = OrderArouterPath.ORDER_NODAYPARTINGELECHANGES;
        }
        PeriodPointBean bean = OrderDetailsUtils.getBeanByEnergyByMonthDetailList(mCurrentMonth, mEnergyByMonthDetailList);
        ARouter.getInstance().build(aRouter_url)
                .withString(ArguConstant.RELATIONID, mIndentOrContractBean.getRelationId())
                .withString(ArguConstant.PACKAGEID, dataDTO.getPackageId())
                .withString(ArguConstant.MONTH, mCurrentMonth)
                .navigation();
    }

    private void djbgcx() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage("是否确认撤销电价变更申请？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.cancelPriceChange(relationId);
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }

    private void dlbgcx() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage("是否确认撤销电量变更申请？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.cancelPowerChange(relationId);
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }

    private void djbgqr() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage("是否同意电价变更？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
                String relationId = mIndentOrContractBean.getRelationId();
                PackageOrdersBean.DataBean bean =
                        OrderDetailsUtils.getPackageOrdersBean(mCurrentMonth, mPackageOrdersBeanList);


                ARouter.getInstance()
                        .build(OrderArouterPath.ORDER_CONFIRMORDER)
                        .withString("mRelationId", relationId)
                        .withString("monthDate", bean.getMonthDate())
                        .withInt("pageFlag", 3)
                        .navigation(OrderDetailsActivity.this, 1100);

//                        mPresenter.confirmPriceChange(relationId, bean.getMonthDate());
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }

    private void djbgbh() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage("是否驳回电价变更？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.rejectPriceChange(relationId);
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }

    private void jchy() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage((TextUtils.isEmpty(mIndentOrContractBean.getConstrFee()) ? "" :
                "本次解约每MWh电量需要承担" + mIndentOrContractBean.getConstrFee() + "元解约金，") + "是否确认要解除该合约？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();

                DialogUtil.showInputCodeDialog(mContext, 1,
                        new DialogUtil.OnInputCodeVerifyCodeListener() {
                            @Override
                            public void onVerifyCode() {
                                String relationId = mIndentOrContractBean.getRelationId();
                                mPresenter.relieveContract(relationId);
                            }
                        });
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }

    private void hyjccx() {
        CommonDialog dialog = new CommonDialog(mContext);
        dialog.setTitle("提示");
        dialog.setMessage("是否确认撤销合约解除申请？");
        dialog.setOnClickBottomListener(new CommonDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                dialog.dismiss();
                String relationId = mIndentOrContractBean.getRelationId();
                mPresenter.cancelRelieveContract(relationId);
            }

            @Override
            public void onNegtiveClick() {
                dialog.dismiss();
            }
        }).show();
    }

//    private void bcxy() {
//
//    }
//
//    private void bcxy() {
//
//    }
//
//    private void bcxy() {
//
//    }

}
